This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, I'm a freshman in college and working on my final. I'm not looking for any free answers, I am just in dire need of assistance. The assignment is a guessing game in which the user is able to guess numbers and is given hints in return in order to guess 3 numbers randomly generated. My problem is that I know more or less exactly what I need to code, I just have very poor syntax and need some help. Anyone on the board want to lend a helping hand over a chat program such as AIM? or reccomend the best way to recieve help on this subject? Any help is much appreciated since attempting to write this code solo is frustrating at every turn. Thanks in advance for reading this.
or reccomend the best way to recieve help on this subject? Any help is much appreciated since attempting to write this code solo is frustrating at every turn.
"Attempting to write this code solo" may be frustrating, but it is the attempt that is the best way to learn. Since you know more or less, what to do, I would recommend that you attempt to start it. The code may be poor syntax, and it may be incorrect, but we can't tell what you are doing wrong, or where you are weak in, otherwise.
Also, if you start it yourself, you can ask more specific questions, instead of just a generic request for help.
I apologize for not using the correct naming format. How's this?
And, I'm going to be on this board for most of the day while i work on this project, so no reply goes unnoticed
Edit: since i dont want to double post, ill just ask some simple questions that are giving me a hard time.
Right now im working on the client for this game, here is the code ive used so far
I get 2 compiler errors from the do/while loop. i assume that my condition statement cannot be right because hints isnt introduced in this java file. Basically i want this code to continue allowing the user to play the game until they guess all 3 numbers in the correct order.
an example of how this game works: code randomly generates 3 numbers, lets say 3 4 5
the user is prompted to guess 3 numbers, if they guess 3 3 3, the code outputs "hot warm warm" because 3 is guessed correctly once, and the "warms" represent that 3 belongs in the guess, but is in the incorrect place. guessing 3 5 4 would produce the same "hot warm warm" output. the goal is to guess all 3 numbers in the correct order, once this is achieved im trying to get the code to ask if the user would like to retry.
also, how would i go about counting the attempts of guesses the user made? id assume it would be something like "everytime a guess is made, i++, where i is the total amount of guesses made during that session of the game [ December 11, 2006: Message edited by: Jim Yingst ]
Joined: Dec 10, 2006
Ok, I figure that since without the entirety of the code ive written displayed, i cannot recieve any reccomendations/solutions. At the moment ive got two files going. One is my client, the java file which is ran to play the game. the other is weak structure of the game, which i recieved some help in writing and there are a couple unexpected outputs. my goal before i move further in this project is to make sure the simple portion of the game works flawlessly. Here is the entirety of the code ive written so far:
The code in GuessingGame.java runs correctly, but the hints recieved rarely are correct. its like i understand why its wrong, but i have no idea how to fix it. The code reads the guesses, but the means in which my hints are given to the guesses is not written correctly. a number guessed, with this current code, can apply for both "Hot" and "Warm" responses. Im a little stumped on how to fix this problem, anyone have any tips on how to make the code output the correct hints? [ December 11, 2006: Message edited by: Jim Yingst ]
It looks as if your hinting code runs through the array of guesses multiple times.
How about running through the array only once, and for each guess going through the following steps:
1) assume that the guess is cold. 2) if the guess is equal to any of the three secret numbers, update guess status to warm. 3) if the guess is correctly placed, update status to hot. 4) add the guess string to the hints string.
If you are still confused, give a hollar - I'll try to be more explicit without depriving you of serious learning opportunities
Joined: Nov 03, 2006
One more thing: It would be very helpful if you added code tags to your code!