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

Okay, so we have a code version of a carnival based Dunk Tank. As long as the there are tries remaining and the tank has

help

2 Answers

OK, there are three positions that need your input. I've labelled them A, B & C.

The sentence should say, while you have remaining tries left and the tank is not dunked, throw the ball.

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

So, point A covers the remaining tries part and is using zero to do something. Let's say remainingTries > 0 as that fills the first part of the sentence. Then point B is joining the first part of the code with the last. It is making sure that the first and last part of the code are both true. The && operator does that, yes?

Lastly, point C is calling the isDunked() method on the tank. That, I'd say, will return a boolean. Looking at the original sentence, we want to make sure the tank is NOT dunked. So point C becomes the NOT operator which is a !.

So the final code looks like:

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

I hope that helps.

Steve.

thank you Steve..... it worked