• Post Reply Bookmark Topic Watch Topic
  • New Topic

Guessing Game  RSS feed

 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys as the title says this is my question but I will save the question for when I fix this smaller bug,

so on to the bug,sometimes when I run the program and click the a button even when the button is not disabled or gameover is true when I click that button nothing happens the text doesn't change to "wrong" or "yes"

it just stays empty and on other times it does indeed change to "yes" or "wrong"

can anyone see the bug or any logic mistakes in my code?

thanks

 
Piet Souris
Master Rancher
Posts: 2042
75
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compare carefully lines 87 and 98. Do you notice a small but important difference?

Also: in your gameOver() method, I made a little modification to make it more clear what is happening:
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Piet I changed it =)



ok guys I got the code working so on to my question

is there any way you can reserve a number?

for example so instead of this code



is there anyway to avoid the while loop so that only one number is taken between these three random numbers for example only one int here can contain the number 5,final won't do in this situation

thanks
 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't think of any.  What do you want the code to do better?
 
Piet Souris
Master Rancher
Posts: 2042
75
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A simple way, if you have java 8, is:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!