0
whats the problem?
why when i enter a correct letter it will still show me the hangman status going down? code: https://code.sololearn.com/c146a4M3tGde
7 Answers
0
Iam getting correct way.. Where is going wrong for ex input..? What is expected output...
0
I'm not sure where is the problem.. everything looks good to me. The expected output is that when I guess a right letter it won't take of tries and display the hangman, it should only happen when the guess is wrong.
0
Your letterInWordCheck() method is incorrect. On line 90 check should be like if (char exists in array) return true. Now it is otherwise.
Also, when you are calling this method on line 190 it should be if (check != true) then tries--;
0
Yes. Make this changes..
line 90:
if (lettersOfSecretWord[m] == usersGuess){
instead of != use ==.
Line 190:
if (letterInWordCheck() == false){
decrease on false, not on true..
0
Aleksandrs and Jayakrishnađźđł , thanks! But what's the difference between what I did and what you said? Its basically the same thing to me .. does java accept false better over true?
0
yahel No. You code was just incorrect.
For example:
word [a, p, p, l, e]
input: p
Your method looked like this:
if (word[m] != input) return true.
This is a problem. Your loop would exit on the first step, because a != p. There is no way to be sure if word actually contains input.
0
Ohhh okay, I get it now. Thanks