public class Carnivore extends Animal { public static final int LIFESPAN = 15; public static final int MAX_FAST = 4; // needs an instance variable to count the number of // generations fasting. private int fast = 0; public void update(Organism[] neighbours) { // calls super.update so that the age is updated! super.update(neighbours); // counting prays int prays = 0; for (int i=0; i 0) fast = 0; else fast++; // applying rules if (fast >= MAX_FAST) alive = false; if (getAge() >= LIFESPAN) alive = false; } public String toString() { return "C"; } }