Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChris Bensen
2,835 Pointsjava 13 error reached end of file while parsing }^
public 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 have a hit!!");
} else {
System.out.println("Whoops that was a miss");
}
}
3 Answers
Philip Gales
15,193 PointsNEW ANSWER: for new code update
Again, you are missing a curly brace for the class.
public 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 have a hit!!");
} else {
System.out.println("Whoops that was a miss");
}
}//closing main
}//closing class
Philip Gales
15,193 PointsYou re missing a closing curly brace, specifically one for the class
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);
}
}
Chris Bensen
2,835 PointsI did that and it still doing the same thing...
Chris Bensen
2,835 Pointswell i updated where the problem is in my code its in the hangman.java
Philip Gales
15,193 PointsIs this your only code?
Chris Bensen
2,835 Pointsyes
Jeremy Hill
29,567 PointsYes I agree it is a good idea to comment your ending brackets, specifically, when you start to change/modify your code you can easily lose track of which bracket goes where.
Chris Bensen
2,835 PointsChris Bensen
2,835 Pointsah ok im having the worst time with these brackets!! thank you for pointing that out
Philip Gales
15,193 PointsPhilip Gales
15,193 PointsNo problem, in school we were told to comment each of our closing curly braces so we would know how many more to add. Ever since I continue doing it.
Amanda Oliver
624 PointsAmanda Oliver
624 PointsThat's not working for me. What am I doing wrong?
public class Hangman {