// Helene Martin, CSE 142 // Cougars move horizontally between pieces of food, always pounce and are displayed // as a blue C before fighting and a red C after. import java.awt.*; public class Cougar extends Critter { private boolean hasFought; private boolean goingWest; // Construct a Cougar object going West public Cougar() { goingWest = true; // hasFough = false; can make explicit if prefer } // Cougars always pounce public Attack fight(String opponent) { hasFought = true; return Attack.POUNCE; } // Cougars are blue before fighting and red after public Color getColor() { if (hasFought) { return Color.RED; } else { return Color.BLUE; } } // Cougars always eat public boolean eat() { // false -> true // true -> false goingWest = !goingWest; return true; } // Toggle between E and W after finding food public Direction getMove() { if (goingWest) { return Direction.WEST; } else { return Direction.EAST; } // W until food, then E, then repeat } // Displayed as a C public String toString() { return "C"; } }