X885: Jeroo giveUpAllFlowers()

Using both a set of if statements and a set of while loops write code to support the following logic. For this question assume you have access to a jeroo variable named trey. This jeroo will have some non-zero number of flowers in its pouch.

If trey sees another jeroo left, right, or ahead of it, trey gives the other jeroo all of the flowers it has. There will never be more than one jeroo for trey to find. Remember, you don't need to turn to give a jeroo a flower!

If trey does not see another jeroo in any direction, it tosses all of the flowers it has.

Your Answer:

Feedback

Your feedback will appear here when you check your answer.