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 Creating the MVP Remaining Tries

christopher allen
christopher allen
6,495 Points

im on the last part of the remaining tries code but keep getting an error

not sure why im getting this error ive checked if anything is spelled wrong but cant see anything maybe im missing something.

Hangman.java:7: error: cannot find symbol
while (game.getRemainingTries > 0){
^
symbol: variable getRemainingTries
location: variable game of type Game

Hangman.java-

Prompter prompter = new Prompter(game); while (game.getRemainingTries > 0){ prompter.displayProgress(); prompter.promptForGuess(); }

Game.java -

public int getRemainingTries(){ return MAX_MISSES - misses.length(); }

Prompter.java-

`public void displayProgress(){ System.out.printf("You have %d tries to try and solve: %s%n", game.getRemainingTries(), game.getCurrentProgress()); }

1 Answer

Tony Gemenie
Tony Gemenie
3,781 Points

Hey man take a closer look at your while statement. What you're trying to do is call a method from game without actually calling it.

christopher allen
christopher allen
6,495 Points

getRemainingTries is supposed to be a method though so how could i make it a variable? do i store the return value inside the method as a variable?

christopher allen
christopher allen
6,495 Points

nevermind i get what you are saying thanks for the help!