/* PERMITTED COMMANDS
move, turnLeft, turnRight, treeLeft, treeRight, treeFront, onLeaf, putLeaf, removeLeaf, mushroomFront
JAVA
if, while, for
To use this code in Greenfoot copy everything below to */
class MyClara extends Clara {
/**
* In the ‘run()’ function you can write your program for Clara
*/
void run() {
// TODO: Write your code below
while(!treeFront())
//
{
removeLeaf();
move();
if(!onLeaf())
{
turnAround();
turnRight();
move();
}
}
removeLeaf();
}
void turnAround()
{
turnLeft();
turnLeft();
move();
}
}
The lady bug needs to eat all the leaves in the order and stop in front of the tree.