aspose file tools*
The moose likes Beginning Java and the fly likes Program doesn't recognise keyboard input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Program doesn Watch "Program doesn New topic
Author

Program doesn't recognise keyboard input

Lucas Lata
Greenhorn

Joined: Dec 17, 2009
Posts: 12
Hi guys,

I managed with help from some of you to build my Dice Game.

It works the way it should be however I still have a small issue.

It should be working in a way that when user in the beginning puts 'r' the dice roll is performed. At the moment no matter what I put and the press Enter the dice roll is performed.

The same is for Roll and Hold. After each dice throw a human can either roll (press 'r') or hold (press 'h').

If I press 'h' then it works fine- computer turn begins, but when I just press enter it rolls again.

why is that?

Below is the code, thanks in advance for any help!

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Look at the first to if-statements in humanGame(). Good luck


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Lucas Lata
Greenhorn

Joined: Dec 17, 2009
Posts: 12
Hi Mr!

Thank you for your hint!!!

PLayed a bit with the code and finally worked it out!

I added a humanGame method after not 'r' or 'h' has been picked and now it works perfectly!

Apprecaite your help!
L

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

That's an improvement however I'd advise you to pay even more attention to your if-statements. Remember:
Lucas Lata
Greenhorn

Joined: Dec 17, 2009
Posts: 12
Thanks Pal!
Will remember that!
L
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Program doesn't recognise keyboard input