Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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