Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Paul Joiner
1,682 PointsAn error with Prompter.java is preventing Hangman.java from compiling, but I'm following the video. Did I miss something
import java.io.Console;
public class Prompter {
private Game mGame;
public Prompter(Game game) {
mGame = game;
}
public boolean promptForGuess(); {
Console console = System.console();
String guessAsString = console.readLine("Enter a letter: ");
char guess = guessAsString.charAt(0);
return mGame.applyGuess(guess);
}
}
3 Answers

dman10345
7,109 PointsIt's a little hard to tell because you aren't providing us with your error or your hangman.java. My first question is, does your apply Guess method return a boolean?
EDIT: After review I found the error
public boolean promptForGuess(); {
You have a semicolon after your method which should not be there. Semicolons in java are used to end statements.
public boolean promptForGuess() {
Would be your proper format. Hope this helps Happy Coding!

Paul Joiner
1,682 Pointspublic class Hangman {
public static void main(String[] args) {
// Enter amazing code here:
Game game = new Game("treehouse");
Prompter prompter = new Prompter(game);
boolean isHit = prompter.promptForGuess();
if (isHit) {
System.out.println("We got a hit!");
} else {
System.out.println("Whoops that was a miss");
}
}
}

Paul Joiner
1,682 PointsGot it. Thanks!

Paul Joiner
1,682 PointsIn game.java, my applyGuess method ends with the line return isHit;

Paul Joiner
1,682 PointsIn game.java, my applyGuess method ends with the line return isHit;
Paul Joiner
1,682 PointsPaul Joiner
1,682 PointsWhen I go to compile Hangman.java I get the following error message: <p>./Prompter.java:10: error: missing method body, or declare abstract
public boolean promptForGuess(); {
^
./Prompter.java:14: error: return outside method
return mGame.applyGuess(guess);
^ </p>