public enum Direction { NORTH(0, -1, 90.0, "N"), EAST(1, 0, 0.0, "E"), SOUTH(0, 1, 270.0, "S"), WEST(-1, 0, 180.0, "W"); static { NORTH.opposite = SOUTH; SOUTH.opposite = NORTH; EAST.opposite = WEST; WEST.opposite = EAST; } private int deltaX; private int deltaY; private double angle; private String abbreviation; private Direction opposite; private Direction(int deltaX, int deltaY, double angle, String abbreviation) { this.deltaX = deltaX; this.deltaY = deltaY; this.angle = angle; this.abbreviation = abbreviation; } public int getDeltaX() { return this.deltaX; } public int getDeltaY() { return this.deltaY; } public String getAbbreviation() { return this.abbreviation; } public double getAngle() { return this.angle; } public Direction getOpposite() { return this.opposite; } public String toString() { return this.abbreviation; } }