Hey~ I'm very new to coding, and my scenario is pretty simple, just a polar bear moving around trying to eat dolphins, but when I tried to make another dolphin appear when the last one's eaten, the error kept popping out and I don't know how to fix it...
My Dolphin code's this:
Thanks a lot!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class ToothedWhale extends Animal
{
public void act()
{
doWhatever();
WorldEdge();
duplicateDolphin();
}
World world= getWorld();
public void doWhatever()
{ turn( Greenfoot.getRandomNumber(10)-5);
move(5);
}
public void WorldEdge()
{if(atWorldEdge())
{ turn(30);
}
}
public void duplicateDolphin()
{if(world.getObjects(ToothedWhale.class).isEmpty())
{ ToothedWhale toothedwhale = new ToothedWhale();
world.addObject( toothedwhale ,1,1);
}
}
}

