i++){
System.out.print("You have made the following guesses: " + guesses[i]);
}
System.out.println("You have " + getMaxNumGuesses() + " remaining.");
}
private char getCh(){
Scanner scanner1 = new Scanner(System.in);
char chosench = scanner1.nextLine().charAt(0);
return chosench;
}
private boolean gameOver(){
return blank.equals(word);
}
}
When I try to run this code, it says "Cannot make a static reference to the non-static method playGame() from the type Hangman. I'm not sure why Java is producing this error. How am I making a static reference? I have some ideas of fixing this problem (by creating the instance of an object Letter), but I'm not so sure if that's the right way to go from here.
Thanks for all your help!
Follow up question:
// checks if the guessed character is right
private boolean isGuessRight(char chr){
Letter l = new Letter('a',false);
for (int i = 0 ; i < word.length() ; i++){
if (word.charAt(i) == chr && Letter.getRevealed() == false){
Letter.reveal();
return true;
}
else if (word.charAt(i) == chr && Letter.getRevealed()){
return false;
}
}
}
Why can I not call the method getRevealed() from the class Letter? I'm not sure why it gives me the static, non-static error again. getRevealed is non static method and my isGuessRight is also a non-static method. I'm not sure where the clash is happening!