/** * An enumerative type that defines legal moves on a two-dimensional grid. * * One could use integers or characters to represent moves. For example, 1, * 2, 3, 4 could designate up, down, left and right. However, the compiler would * not be able to detect errors such as move = 5, because 5 is a * valid value for an integer. By using an enumerative type, that kind of * errors can be detected at compile-time. */ public enum Move { Up, Down, Left, Right; /** * Caching the array to avoid regenerating it several times */ public static final Move[] moves = Move.values(); }