Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Guessing Game

 
Jacqueline Turof
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started taking programming course in Java and I'm trying to write a guessing game. I would like the user to be able to start the game over again without having to restart the program. Every time I try to set up a loop to do this it never goes through the enter loop again. I'm just not constructing the loop properly, but I'm not sure how I can correct it. Any help or suggestions on how to improve my code would be appreciated. Thanks in advance!

 
fred rosenberger
lowercase baba
Bartender
Posts: 12124
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing i would suggest...use a bunch of System.out.println statements to see what is going on. If something isn't looping like you think it should, print out what you are comparing and prove that is is really equal to what you think it is. odds are it is not.

Print out your "playAgain" variable just before your line 58 and see what it is.
Print out each time you enter the top of a loop, so you know if you are looping (and how many times).
etc.
 
Jacqueline Turof
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the fast reply and the help. I was able to fix my code and have it working now.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12124
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent!!! I'ts always better when you are able to figure it out on your own.

I have been a strong champion of System.out.println() here for debugging...I'm glad it really worked for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic