X920: Practicing Conditionals 1

For this question, we will be working with a subclass of Jeroo called CountingJeroo that tracks the number of hops it has peformed. You can access the number of hops performed so far by running the getHopCount() method.

You will have access to a CountingJeroo object named leon.

For this question write code accomplish following specifications

Write a while loop that will stop after the jeroo has hopped 10 times. Inside the loop

  • If they see a flower ahead they should pick the flower.
  • If they do not see a flower ahead, they should turn right.
  • Either way (regardless if the jeroo sees a flower or not), the jeroo should hop. Be careful! Without this step your loop will run infinitely!

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.