This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Problem with Java Scanner - Please Help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with Java Scanner - Please Help!" Watch "Problem with Java Scanner - Please Help!" New topic
Author

Problem with Java Scanner - Please Help!

Kevin Behr
Greenhorn

Joined: Jun 29, 2006
Posts: 23
Hey all - so I am creating a non-graphical version of the game Mastermind (which entails guessing a secret color code within the fewest amount of tries possible - here is a link containing an example [http://www.irt.org/games/js/mind/]).

With my game, you first choose for either a computer-generated secret code or a human entered code, and then the player is prompted to enter the first guess of the color sequence. It should go like this:

Color 1: ____ [ENTER]
Color 2: ____ [ENTER]
Color 3: ____ [ENTER]
Color 4: ____ [ENTER]

But insted, it goes like this...

Color 1: Color 2: ____ [ENTER]
Color 3: ____ [ENTER]
Color 4: ____ [ENTER]

The problem lies within my ConfirmYes() and my ConfirmNo() methods. Could you please try giving my code a run and maybe seeing where the problem lies? Thanks!



Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Note that according to the Javadocs, nextLine() doesn't block. But the next() method may.
Kevin Behr
Greenhorn

Joined: Jun 29, 2006
Posts: 23
That did the trick, thanks alot!
 
jQuery in Action, 2nd edition
 
subject: Problem with Java Scanner - Please Help!
 
Similar Threads
Enum doubt
Feedback.
diamond pattern without parse.int (Someone help me T.T) :cry:
Need help in parsing text file with list to XML
Scanner class