I'm creating a word search game program for a project, and want to know if what I want to do is possible. Below is the isPuzzleWord method that followed the guidelines of my project, namely that it has to return the word class object from an array if the word is right, or null if it is not. My isPuzzleWord method works fine.
public static Word isPuzzleWord (String guess, Word[] words) {
for(int i = 0; i < words.length; i++) {
if(words[i].getWord().equals(guess)) {
return words[i];
}
}
return null;
}
My question is how I can incorporate both of these responses into an if statement so that I can continue the game if the guess was right or provide feedback to the user if the guess was wrong.
public static void playGame(Scanner console, String title, Word[] words, char[][] puzzle) {
System.out.println("");
System.out.println("See how many of the 10 hidden words you can find");
for (int i = 1; i <= 10; i++) {
displayPuzzle(title, puzzle);
System.out.print("Word " + i + ": ");
String guess = console.next().toUpperCase();
isPuzzleWord(guess,words);
if (
}
}