• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GuessGame with three classes (please help)

 
david torrance
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I've been struggling with this program that keep running loop forever. It supposed be stop when player get the right guess number. I couldn't find what's wrong with my program So, please anyone could help me? It's due this Tuesday, May 7. THANK YOU!!


 
John Corkrend
Ranch Hand
Posts: 51
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use code tags in the future so that your code is easier to read.








Besides that in your logic you should use .equals instead of ==. But I am not the most experienced so I may be wrong, if someone else on the forum would make sure that is right.
If there are any other errors please ask.
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, and welcome to CodeRanch!
I've edited your post to include code tags, which makes the code segments of your post a bit easier to read. You can read up how to UseCodeTags (<-click) to find out how this works.
 
Jelle Klap
Bartender
Posts: 1951
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your program will only break from the loop if either player has made a correct guess.
The range for the number to guess is defined by this code segment:


While the number range a player can guess is defined by this code segment:


The problem is with these ranges. If you figure out what number ranges each of the code fragments can generate, you'll have solved your problem.
 
david torrance
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah I thought there was nothing wrong with loop. You solved a problem that my program is now running without any errors and will use code tags next time. Thank you so much and this forum rocks! =D
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic