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

2011/11/17

I need help please.

1
2
davmac davmac

2011/11/17

#
"if (getObjects(Worm.class) == null)" Didn't know you could do that :0. I do now, thanks!
Actually, this code is wrong. If you check the documentation for the "getObjects" method (in the World class) you will see that it returns a List. It can never return null, but it may return an empty list! The corrected version of the above code would be:
if (getObjects(Worm.class).isEmpty())
See the documentation for the List interface.
Royalblue64 Royalblue64

2011/11/17

#
darkmist255 wrote...
Well... "Greenfoot.stop();" would stop it. 7th is pretty easy if you just mean stop.
Yeah I know that stopping it is easy. The hard part is getting the crabs to count the worms they eat properly. If there is more than one crab eating the worms, the game will only stop when you get a SINGLE crab to eat the specified amount. If you just put it in the crab class to add one every time, it will apply to the individual crabs not the whole class of crabs.
darkmist255 darkmist255

2011/11/17

#
@Royalblue64 Ahh, I see what you meant now. @davmac (getObjects(Worm.class).isEmpty()) Thanks :D. Could come in useful in many cases.
darkmist255 darkmist255

2011/11/17

#
delmar wrote...
I think you guys are mixing something up here. You're confusing "explain to me how you do this" with "giving me the solution". If you really "wanna be a head of the ball game" you need to be able to do more than copy down the code. How about explaining them one by one?
I guess, I was hoping he would read through and try to interpret. That's generally how I read source code from other people, not just copying.
Royalblue64 Royalblue64

2011/11/18

#
darkmist255 wrote...
(getObjects(Worm.class).isEmpty())
Is this a real method? isEmpty?
mjrb4 mjrb4

2011/11/18

#
Royalblue64 wrote...
Is this a real method? isEmpty?
It definitely is!
You need to login to post a reply.
1
2