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

reached end of file while parsing. HELP

it's still not working when I add a brace. I also tried adding a brace in the "Prompting.java" it doesn't work. There has to be some type of system error as I have gone over it a million times to no avail.

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.promtForGuess(); 

        if (isHit) {
            System.out.println("We got a hit!");
        } else {
            System.out.println("Whoops that was a miss");
        }  
    }

}
J.D. Sandifer
J.D. Sandifer
18,813 Points

It looks like there is at least one problem in this section:

        Prompter prompter = new Prompter(game); 
        boolean isHit = Prompter.promtForGuess();

Looks like the second line should say prompter.promptForGuess();. 1) Lower case prompter object name and 2) the name of the function is misspelled - might not technically be an error if it matches the name in the Prompter definition, but both should be corrected.

Neither of these would give you an end of file error, though. Could you post the rest of your code for this - Prompter and Game?

(I also edited your post so the code was all in a code box.)

Simon Coates
Simon Coates
28,694 Points

Braces are fine in the code posted. if you post more code or maybe a link to a workspace snapshot (see https://teamtreehouse.com/library/previews-and-snapshots )

2 Answers

When it says "reached the end of file without parsing" you are missing a closing bracket somewhere. It sucks but you should go through all the areas with brackets and make sure that they have proper closing brackets. This happens to me all the time and I'm sure thats why Craig always makes opening and closing brackets when he starts a new section of code. The error is not in that class, i checked already, so i would look at the other classes.

Andrew Robida
Andrew Robida
15,296 Points

parsing is definitely curly brackets problems so make sure you check all other files for loops missing the {