// CSE 142 Homework 8 (Critters), Marty Stepp // // An ExampleCritter is displayed as %. // They always pick ROAR in a fight. // They move 2 steps left, 2 steps right, and repeat. // public class ExampleCritter extends Critter { private int moves; public ExampleCritter() { moves = 0; } public Direction getMove() { moves++; // moves 1 2 3 4 5 6 7 8 9 0 ... // W W E E W W E E W W ... if (moves % 4 == 1 || moves % 4 == 2) { return Direction.WEST; } else { return Direction.EAST; } } public Attack fight(String opponent) { return Attack.ROAR; } public Color getColor() { return Color.RED; } public String toString() { return "%"; } }