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 Determining if it is Solved

kaushlender kumar
kaushlender kumar
1,275 Points

Okay, so we have a code version of a carnival based Dunk Tank. Please fill in the blanks with proper code for the while

Okay, so we have a code version of a carnival based Dunk Tank. Please fill in the blanks with proper code for the while loop.

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

Ken Alger
Ken Alger
Treehouse Teacher

Kaushlender;

Can you post the code you have tried, please? It will help others to see the code.

Thanks,

Ken

kaushlender kumar
kaushlender kumar
1,275 Points

Okay, so we have a code version of a carnival based Dunk Tank. Please fill in the blanks with proper code for the while loop.

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

1 Answer

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hello, the first case it is asking you to meet is making sure that there are remaining tries, you can do this first making sure that the remaining tries is greater than 0.

So remainingTries > 0.

Next it is asking you to make sure that the other condition will pass as well, this looks like an excellent case for && operand. It will make sure both conditionals evaluate to true before moving onto the throw ball code.

Finally it is asking us to make sure that dunk tank has not already been dunked, remember that we can use ! to mean not. so !dunkTank.isDunked();

Over all it should look like this

while (remainingTries > 0 &&  !dunkTank.isDunked()) { 
throwBall(); 
}

Hope this helps. let me know if it doesn't.