// CSE 142, Autumn 2010, Jessica Miller // A class to represent a Snake critter. // Snakes move south in a growing zig zag motion. public class Snake extends Critter { private int steps; // the number of times we have gone in a direction private int cycle; // length of E/W direction public Snake() { steps = 0; cycle = 1; } public Direction getMove() { steps++; if (steps > cycle) { steps = 0; cycle++; return Direction.SOUTH; } else if (cycle % 2 == 1) { return Direction.EAST; } else { return Direction.WEST; } } public String toString() { return "S"; } }