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

Gregory Serfaty
Gregory Serfaty
37,140 Points

fill the blank java object

I think my english is very bad ;) Could you help me for this validation? Thx

while (remainingTries ----- --------  0 ------  dunkTank.isDunked()) {
  throwBall();
}

2 Answers

Stone Preston
Stone Preston
42,016 Points

this question can be a little hard if you arent familiar with carnival style dunk tank games (you can read about the game here)

you only want to throw the ball if the person has tries remaining AND the tank has not been dunked.

we can make sure the remaining tries is greater than 0 using the > operator. isDunked returns true if it has been dunked, so to test if it has NOT been dunked we can use the boolean not unary operator !. we need to make sure both of the statements are true, so we join them with the && operator. Remember that two statements joined with the && operator will only evaluate to true if BOTH statements are true.

// throwbBall if there are tries remaining and the tank has not been dunked
while (remainingTries ----->-------  0 ---&&--- ---!---  dunkTank.isDunked()) {
  throwBall();
}

you can see a list of the Equality, Relational, and Conditional operators (this includes > and &&) and more information on them in the documentation

you can also see a list of the Unary operators (this includes !) and more information on them here

Gregory Serfaty
Gregory Serfaty
37,140 Points

Ok thx , effectively i didn't know this game ;) When we have the rules it is simpler ;)