This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

Game/maniac
Game/maniac presents ...

2012/2/19

A flies life

4 eggs, hatch into 4 maggots, which eat burgers, and turn into flies, which feed the spider, and can make eggs

2788 views / 4 in the last 7 days

5 votes | 0 in the last 7 days

Tags: simulation with-source life spider fly maggot egg

This scenario is a member of: Games/Simulations by Game/maniac


open in greenfoot
Your browser does not support the canvas tag.
danpostdanpost

2012/2/19

I'll download and take a look.
Game/maniacGame/maniac

2012/2/19

thx
Game/maniacGame/maniac

2012/2/19

the die code is located in Fly.class
danpostdanpost

2012/2/19

Reverse the last two lines of code in the Fly class (add the burger before removing fly).
A new version of this scenario was uploaded on Sun Feb 19 19:19:47 UTC 2012
Game/maniacGame/maniac

2012/2/19

it works thx
danpostdanpost

2012/2/19

The terminal window is there to assist you. You were getting a message that started with: Line 1: java.lang.NullPointerException Line 2: at Fly.die(Fly.java:135) Line 3: at Fly.act(Fly.java:32) Line 1 tells you why the scenario stopped (the error type) Line 2: tells you where in your code the error occurred (line 135 of the Fly class in the die() method) Line 3: may show where the method was called from (line 32 of the Fly class in the act() method) Lines 2 will not always be immediately after the error type, but will be somewhere in the message (it will be the first one that is recognizably in your scenario)
danpostdanpost

2012/2/19

The 'NullPointerException' is one of the most common run-time error messages. It is telling you that you are trying to do something to nothing as if it were something. That kind of sounds strange, I guess, but in your case, after the fly is removed, it no longer has a world; therefore 'getWorld()' in the next line becomes 'null'; hence, the 'NullPointerException'.
Game/maniacGame/maniac

2012/2/19

Thx for the advice
A new version of this scenario was uploaded on Sun Oct 07 16:55:13 UTC 2012 bug fix

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Cheribasa Gargol Tasharoo -nic- kevj