Hello,
I'm trying to programm "Deal or no Deal", but I get this Errormessage:
java.lang.NullPointerException
at Rechner.RandomWert(Rechner.java:68)
at Rechner.Angebot(Rechner.java:79)
at KOFFER2.click(KOFFER2.java:37)
at KOFFER2.act(KOFFER2.java:17)
at greenfoot.core.Simulation.actActor(Simulation.java:604)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:562)
at greenfoot.core.Simulation.runContent(Simulation.java:221)
at greenfoot.core.Simulation.run(Simulation.java:211)
The code:
I hope someone can help me. Thanks in advance!
int RandomZahl()
{
RandomZahl = Greenfoot.getRandomNumber(((DealWorld) getWorld()).Kofferungeöffnet);
return RandomZahl;
}
int RandomWert()
{
int aktuell = kofferbeträge[RandomZahl()]; //in this line I get the error
for (int i = RandomZahl; i< kofferbeträge.length - 1; i++)
kofferbeträge[i] = kofferbeträge[i+1];
return aktuell;
}
void Angebot()
{
int RandomWert = RandomWert();
Gesamtsumme = Gesamtsumme - RandomWert;
Angebot = Gesamtsumme/((DealWorld) getWorld()).Kofferungeöffnet * ((DealWorld) getWorld()).click/10;}
