Professional Documents
Culture Documents
1. Keep two copies of the word as instance variables: one with the
word itself (named word), and one with the copy of the word the user
sees (with *’s in place of letters they haven’t guessed yet) (named
blankWord).
2. If you do the above, you can use this code to store a correct copy of
the blank word:
if(isInWord(word,guess)) {
correctGuesses += guess;
blankWord =
word.replaceAll("[^"+correctGuesses+"]", "*");
}
4. Detecting when the user has won can then be done by checking if
blankWord equals word.