Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hangman BufferReader ??

 
Paul Yule
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would probably just check to see if there are any of the replacement letters left in the word. Hmm, I'll give an example.


This is what I would use to fill the word with characters to hide the word. Ignoring spaces because we need to keep spaces in case it's multiple words. So "I heart JR" would appear "- ----- --" Whenever someone made a guess I would check to see if there are any dashes left in the word after theirguess. If not, it's complete. Your solution of not allowing the same letter to be guessed again is nice because it has the added advantage of requiring you to keep all the letters previously guessed which could be cool to show to the user before they guess.
 
Kris Danielewski
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found resolution I transfered back the user input array into a String and compare it to the hidden word :>
Now if you press letter which hiddenword contains its still increase the counter but you will not win the game and small bit is quite important.
Counter may be greather then or equal.
 
Kris Danielewski
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys , thanks for your help
I finally made it work :]
Feel quite good as it was my first application, not completly done by myself, but thanksfully to your advices I found the answers.
I had 3 counters,
int wrong; to store bad guesses
int guessright; to store good ones
int fwronf; to so store multiplications of bad ones...

setting counters to 0; every time do..while loop starts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic