Hey guys I need help asap please. So in greenFoot I use the myClara scenario its for uni. And I'm stuck on this, the goal is to move across a trail of leafs, removing the leafs as you move. Once you get off track or off the leafs you must get back on track I made a function to do this, but my problem is Clara keeps moving after she has collected all the leafs. I'm really stressed, I have spent over 8 hours in one day over this and I can't figure it out. Here is my code and a picture of what it needs to look like when its finished. Also keep in mind there are 3 other words which look similar and the code must work for those worlds also, I just need to make her stop after collecting all the leafs.
This is the photo of how it starts, and how it should result: http://tinypic.com/view.php?pic=2v2jjbn&s=8#.VR4_0fmUc1J
This is my code:
public void run()
{
// TODO: Write your code below
// TODO: Write your code below
while(onLeaf())
{
removeLeaf();
move();
while(!onLeaf())
{
getBackOnTrack();
}
}
}
public void getBackOnTrack()
{
turnLeft();
turnLeft();
move();
turnLeft();
move();
}
}

