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

2012/12/14

adding a counter and making it work

ctgreenfoot ctgreenfoot

2012/12/14

#
I have recently started using Greenfoot and have been working on the little crab scenario. However, I have encountered a problem where i have created a counter but am not sure how to make the numbers change when the crab eats a worm.
vonmeth vonmeth

2012/12/14

#
Find the code in the Crab class (it should be in a method that looks for the worm) where the crab 'eats' the Worm class. You will want to assign a new value to your counter there. Something like, " counter = counter + 1; ", or you can simplify that line and use the increment operator - "counter++;" - that will increase the counter by 1.
You need to login to post a reply.