NOTES: Loops and conditions to control program flow part 2

Loops and conditions can be used in the Main method and in Jeroo methods.

WHILE Example: Kim picks all flowers in a line of flowers ahead, then turns left
as part of the main method as part of an original method named pickRow
method main()
{ Jeroo kim = new Jeroo( ); while ( ___________________________)
{ kim.hop(); kim.pick(); }
kim.turn(LEFT);
}
method pickRow( )
{
 
 


}

Compound Conditions: && (and), || (or), !(not) Using the examples, write the code for these conditions:

  1. If there is not a Jeroo to the right of Lethia ________________________________________________________
  2. If Bernie has at least one flower and there is a net ahead of Bernie. _____________________________________
  3. If it is clear ahead or to the right of Liz __________________________________________________________
  4. If Dave is facing south and there is water to his left. _________________________________________________

Nested control structures:

Circle the correct way to say:
“there is not a net on the left or right”
1.! isNet(LEFT) || !isNet(RIGHT)
2.!isNet(LEFT) && !isNet(RIGHT)
How do you know that a Jeroo has reached the end of the island?
How do you say “ keep hopping until you reach the end of the island”?

Copy the Final Version of the solution to:
Remove all the nets on Jessica's right side as she hops all the way across the island.