In this task we have to help the frog cross a busy road.   We could just charge straight across the road but it’s more than likely we’ll get run over, so we need to do things in a more controlled way.   The instructions we’ll use are:

frogRight(numberOfSteps) Moves the frog numberOfSteps to the right
safeOnRight() Evaluates to true if there is no traffic approaching from the right
nextToRoad() Evaluates to true if the frog is directly next to a road

We will use the instruction frogRight() to move up to the edge of the road.   Then we will loop while nextToRoad() evaluates to true:

while( nextToRoad() )
{
}

In that loop we will test if the road is safeOnRight().  If it is, we will move the frog right.  This will cause nextToRoad() to evaluate to false, causing the loop to end.

Tasks: