Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program doesn't recognise keyboard input

 
Lucas Lata
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the first to if-statements in humanGame(). Good luck
 
Lucas Lata
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's an improvement however I'd advise you to pay even more attention to your if-statements. Remember:
 
Lucas Lata
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pal!
Will remember that!
L
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic