// This class was suggested during the B lecture for CSE142. The Stuart // objects infect if they can and otherwise use a random object to randomly // select between the other three possible moves. import java.awt.*; import java.util.*; public class Stuart extends Critter { private Random r; public Stuart() { r = new Random(); } public Action getMove(CritterInfo info) { if (info.getFront() == Neighbor.OTHER) { return Action.INFECT; } else { int which = r.nextInt(3); if (which == 0) { return Action.LEFT; } else if (which == 1) { return Action.RIGHT; } else { // which == 2 return Action.HOP; } } } public Color getColor() { return Color.CYAN; } public String toString() { return "#<3"; } }