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) Delivering the MVP Validation

leo 001
leo 001
2,357 Points

why promptForGuess has to return a boolean value?

why promptForGuess has to return a boolean value?

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

We use this to check and see if the guess was a hit or not. This allows the prompting code to handle the different cases.

Make more sense?

Florian Janosch
Florian Janosch
871 Points

I have the same problem as leo 001... Why would we want to return the isHit in the last line of promptForGuess???

leo 001
leo 001
2,357 Points

Thanks for replying. When we use it in the play() method, we just call it, but it does not return the boolean to anything, is that ok? should it be return void for this case?

public void play(){ while(mGame.getRemainingTries()>0 && !mGame.isSolved()){ displayProgress(); promptForGuess(); }