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

1st Oct 2020, 2:10 PM
Yahel
Yahel - avatar
7 Respostas
0
Iam getting correct way.. Where is going wrong for ex input..? What is expected output...
1st Oct 2020, 2:51 PM
Jayakrishna 🇮🇳
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.
1st Oct 2020, 3:06 PM
Yahel
Yahel - avatar
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--;
1st Oct 2020, 4:33 PM
Aleksandrs
Aleksandrs - avatar
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..
1st Oct 2020, 6:04 PM
Jayakrishna 🇮🇳
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?
1st Oct 2020, 9:26 PM
Yahel
Yahel - avatar
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.
2nd Oct 2020, 5:35 AM
Aleksandrs
Aleksandrs - avatar
0
Ohhh okay, I get it now. Thanks
2nd Oct 2020, 12:01 PM
Yahel
Yahel - avatar