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

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!