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

Leonard Fierro
Leonard Fierro
1,123 Points

Getting an error message while trying to compile Hangman.java

I keep getting these 5 errors when trying to compile Hangman.java:

./Prompter.java:9: error: illegal start of expression
public boolean promptForGuess() {
^
./Prompter.java:9: error: ';' expected
public boolean promptForGuess() {
^
./Prompter.java:15: error: reached end of file while parsing
}
^
Hangman.java:7: error: cannot find symbol
boolean isHit = prompter.promptForGuess();
^
symbol: method promptForGuess()
location: variable prompter of type Prompter
./Prompter.java:13: error: incompatible types: unexpected return value
return mGame.applyGuess(guess);
^
5 errors

Totally lost. I don't understand what any of these messages mean. Can somebody help me out? Thanks!

1 Answer

Florian Tönjes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 Points

Hey Leonard,

it's hard to say what is causing the error without seeing your code. It looks like you messed up with the brackets somewhere. You're either missing one or having one too much.

Kind Regards, Florian

Leonard Fierro
Leonard Fierro
1,123 Points

Got it! It was my bracket on

public Prompter(Game game) { mGame = game; } ^ I was missing that one.

Thanks a lot!