• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Java Scanner - Please Help!

 
Kevin Behr
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that according to the Javadocs, nextLine() doesn't block. But the next() method may.
 
Kevin Behr
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That did the trick, thanks alot!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic