/** * Direction.java * CIS 260 * David Klick * 2012-03-09 * * This enum is designed to provide an enumerated * set of directions for the Maze project. It has * enhancements that specify where that direction * goes in a grid, what the opposite direction is, * and provides an initial for that direction. * * @author David Klick * @version 1.0 2012-03-09 */ public enum Direction { NORTH (-1, 0), EAST (0, 1), SOUTH (1, 0), WEST (0, -1); public final int deltaRow; public final int deltaCol; Direction(int deltaR, int deltaC) { deltaRow = deltaR; deltaCol = deltaC; } public Direction opposite() { Direction d = null; switch (this) { case NORTH: d = SOUTH; break; case SOUTH: d = NORTH; break; case EAST: d = WEST; break; case WEST: d = EAST; break; } return d; } public String toString() { String s = null; switch (this) { case NORTH: s = "N"; break; case EAST: s = "E"; break; case SOUTH: s = "S"; break; case WEST: s = "W"; break; } return s; } }