Okay.
Here is what I've done: in schildkroete.class I put
and in the act()
Compilation is okay.
But when I run this szenario, it stops when the first turtle get removed with a message
What went wrong?
/** * liefert normalerweise true, wird aber hier auf false gesetzt, * damit der Sound nicht zu früh startet. * * @return false, solange noch nicht die erforderliche Anzahl von Objekte erreicht ist */ public boolean sound = false;
if(!sound) { if(getWorld().numberOfObjects() == 204) { Greenfoot.playSound("happy-birthday.wav"); sound = true; } }
java.lang.NullPointerException
at Schildkroete.act(Schildkroete.java:96)
which is the line with
if(getWorld().numberOfObjects() == 204)