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 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