You need to count the worms your crab has already eaten.
Then you check this value in the constructor of your worm class and it you have eaten more than 10 worms you change the image of your worm using setImage();
I've tried this (this is the worm subclass) but it keeps on saying "cannot find variable wormsEaten". what should i do?
import greenfoot.World;
import greenfoot.Actor;
/**
* Worm. A sand worm. Very yummy. Especially crabs really like it.
* Author: Michael Kolling
*/
public class Worm extends Animal
{
public void populateRed()
{
if (wormsEaten = 10);
setImage(redWorm.png);
}
}
If the compiler cant find the variable wormsEaten you haven't declared it or you have declared it but somwhere (probably in an othere class) where you cant find it from your worm class.
Have you got a variable wormsEaten somewhere?
If yes show us the code then we can help you.