• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Java Scanner - Please Help!

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!



 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That did the trick, thanks alot!
reply
    Bookmark Topic Watch Topic
  • New Topic