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.

ISAIAH S
1,409 Pointserror: ^ ./Game.java:34: error: ';' expected...
Here's my error:
^
./Game.java:34: error: ';' expected
public int getRemainingTries() {
^
./Game.java:35: error: incompatible types: int cannot be converted t
o String
return MAX_MISSES - mMisses.length();
^
./Prompter.java:11: error: cannot find symbol
while(mGame.getRemainingTries() > 0) {
^
symbol: method getRemainingTries()
location: variable mGame of type Game
./Prompter.java:26: error: cannot find symbol
mGame.getRemainingTries,
^
symbol: variable getRemainingTries
location: variable mGame of type Game
5 errors
treehouse:~/workspace$
Here are my workspaces:
Game.java:
public class Game {
public static final int MAX_MISSES = 7;
private String mAnswer;
private String mHits;
private String mMisses;
public Game(String answer) {
mAnswer = answer;
mHits = "";
mMisses = "";
}
public boolean applyGuess(char letter) {
boolean isHit = mAnswer.indexOf(letter) >= 0;
if (isHit) {
mHits += letter;
} else {
mMisses += letter;
}
return isHit;
}
public String getCurrentProgress() {
String progress = "";
for (char letter: mAnswer.toCharArray()) {
char display = '-';
if (mHits.indexOf(letter) >= 0) {
display = letter;
}
progress += display;
}
return progress;
public int getRemainingTries() {
return MAX_MISSES - mMisses.length();
}
}
}
Hangman.java:
public class Hangman {
public static void main(String[] args) {
// Enter amazing code here:
Game game = new Game("treehouse");
Prompter prompter = new Prompter(game);
prompter.play();
}
}
Prompter.java:
import java.io.Console;
public class Prompter {
private Game mGame;
public Prompter(Game game) {
mGame = game;
}
public void play() {
while(mGame.getRemainingTries() > 0) {
displayProgress();
promptForGuess();
}
}
public boolean promptForGuess() {
Console console = System.console();
String guessAsString = console.readLine("Enter a letter: ");
char guess = guessAsString.charAt(0);
return mGame.applyGuess(guess);
}
public void displayProgress() {
System.out.printf("You have %d tries left to solve: %s\n",
mGame.getRemainingTries,
mGame.getCurrentProgress());
}
}
2 Answers

Steve Hunter
57,682 PointsPerhaps, try changing:
public void displayProgress() {
System.out.printf("You have %d tries left to solve: %s\n",
mGame.getRemainingTries,
mGame.getCurrentProgress());
}
to
public void displayProgress() {
System.out.printf("You have %d tries left to solve: %s\n",
mGame.getRemainingTries(),
mGame.getCurrentProgress());
}
i.e. add open and closing brackets for the mGame.getRemainingTries()
method.

Steve Hunter
57,682 PointsI think this might be missing a closing curly brace too:
public String getCurrentProgress() {
String progress = "";
for (char letter: mAnswer.toCharArray()) {
char display = '-';
if (mHits.indexOf(letter) >= 0) {
display = letter;
}
progress += display;
}
return progress;

ISAIAH S
1,409 PointsIt worked!!

Steve Hunter
57,682 Points:-))