// The Dog2 class is a variation of the Dog class that keeps a static counter // of how many Dog2 critters have been constructed and what number this critter // was in that sequence (first, second, third, etc). It displays itself using // these two numbers, as in, "7 of 9". import java.awt.*; public class Dog2 extends Critter { private int count; private static int ourCount; private int myCount; public Dog2() { count = 0; ourCount++; myCount = ourCount; } public Action getMove(CritterInfo info) { if (info.getFront() == Neighbor.OTHER) { return Action.INFECT; } else if (count < 5) { count++; return Action.LEFT; } else { count = 0; return Action.HOP; } } public Color getColor() { return Color.PINK; } public String toString() { return myCount + " of " + ourCount; } }