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 trial

Java Java Objects (Retired) Creating the MVP Prompting for Guesses

java 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

NEW 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

ah ok im having the worst time with these brackets!! thank you for pointing that out

No 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.

That's not working for me. What am I doing wrong?

public class Hangman {

public static void main(String[] args) {
    // Enter amazing code goes 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");
  }
}

You 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);
  }
}

I did that and it still doing the same thing...

well i updated where the problem is in my code its in the hangman.java

Is this your only code?

yes

Yes 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.