Code: Select all
if (secret.contains(guess)) {
System.out.println(guess + " was in the word!");
// Replace the necessary underscores in the progress string with the guess
for (int i = 0; i < secret.length() - 1; i++) {
if (secret.substring(i, i + 1).equals(guess)) {
progress = progress.replace(progress.substring(i, i + 1), guess);
}
}
}
< /code>
guess
Mit anderen Worten,
Erwartete Ausgabe für das geheime 'Alphabet' und die Vermutung 'a': < /p>
a___a___
< /code>
Output I actually get:
aaaaaaaa
< /code>
How do I fix this?