my dog learned polymorphism*
The moose likes Beginning Java and the fly likes GuessGame with three classes (please help) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "GuessGame with three classes (please help)" Watch "GuessGame with three classes (please help)" New topic
Author

GuessGame with three classes (please help)

david torrance
Greenhorn

Joined: May 04, 2013
Posts: 3
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

Joined: Oct 27, 2012
Posts: 51

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

Joined: Mar 10, 2008
Posts: 1667
    
    7

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.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1667
    
    7

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

Joined: May 04, 2013
Posts: 3
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GuessGame with three classes (please help)
 
Similar Threads
IDE or bust?
Very new to java
GuessGame Errors From Head First Java
Please Help with Guessing Game (Head First Java)
Head First Java Book, Chapter 2