// Zorah Fung, CSE 142 // This class represents a Critter of type Cougar. Cougars always eat // POUNCE when fighting and appear as a "C." Before fighting they appear // blue, but change to red after their first fight. Cougars move from // side to side, switching from WEST to EAST or vice versa when they encounter // food. import java.awt.*; public class Cougar extends Critter { private boolean hasFought; private boolean west; // Constructs a new Cougar public Cougar() { hasFought = false; west = true; } // Always eats public boolean eat() { west = !west; return true; } // Appears as a "C" public String toString() { return "C"; } // Always Pounces public Attack fight(String opponent) { hasFought = true; return Attack.POUNCE; } // Returns red if the Cougar has fought before, and blue otherwise public Color getColor() { if (hasFought) { return Color.RED; } else { return Color.BLUE; } } // Initially moves west but switches between east and west each // time this Cougar encounters food public Direction getMove() { if (west) { return Direction.WEST; } else { return Direction.EAST; } } }