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

why at prompter class set boolean value false for isHit and IsValidGuess ?

Hello Guys :)

I don't quit understand why Craig set two boolean values for "isHit" and "IsValidGuess" To "false" at the Prompter Class ? actually i didn't get what he did in the Prompter class , it made me a bit confused :S

if someone can simplifies it to me i will be very thankful...

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Well these two isHit and isValidGuess are set to false to start with because otherwise we'd be assuming that whatever the user input is a valid guess and it is a hit. The isHit is going to keep track of whether or not we've guessed that letter already. The isValidGuess makes sure we're not putting in strange things as guesses like numbers, punctuation marks, and full strings. It's just making sure the letter is actually a letter.

Hope this helps! :sparkles:

that makes sense , thanks for clarifying things up ...

annient
annient
Courses Plus Student 1,708 Points

Thanks for your explanation. I have one more question, I am confused with the part while (!isValidGuess) I know ! means NOT, but look at the while loop, I don't get it. Please help!