do {
System.out.println("Word: " + secretWord.getWordMask());
//System.out.print("Guesses: " + guesses);
System.out.print("Enter your guess: ");
Scanner keyboard = new Scanner(System.in);
String guess = keyboard.next();
WordHider revealChar = new WordHider();
revealChar.revealLetter(guess);
System.out.println(revealChar.getWordMask());
secretWord.revealLetter(guess);
} while ();
我的代码现在所做的是不断地向用户询问一个字母,然后如果它是单词的一部分,则显示它。我在另一个类中有另一种方法,可以检查是否找到隐藏的单词
public boolean isHiddenWordFound() {
for (int i = 0; i < wordMask.length(); i++) {
if(wordMask.charAt(i) == HIDE_CHAR.charAt(0)) {
return false;
我需要弄清楚如何对while
零件进行检查。但我简直不知所措,有什么想法吗?