Enum Direction

java.lang.Object
  extended by java.lang.Enum<Direction>
      extended by Direction
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Direction>

public enum Direction
extends java.lang.Enum<Direction>

An enumeration type that represents the four cardinal directions in a maze. We use an enumeration because we know in advance that there will be exactly four instances of Direction. We also include some helper methods for moving clockwise and counter-clockwise given a direction.

Author:
Albert J. Wong (awong@cs), Laura Effinger-Dean (effinger@cs)

Enum Constant Summary
EAST
          The direction representing east.
NORTH
          The direction representing north.
SOUTH
          The direction representing south.
WEST
          The direction representing west.
 
Method Summary
 Direction clockwise90()
          Returns the direction that is 90 degrees clockwise from the current direction.
 Direction counterClockwise90()
          Returns the direction that is 90 degrees counter-clockwise from the current direction.
static Direction valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static Direction[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NORTH

public static final Direction NORTH
The direction representing north.


EAST

public static final Direction EAST
The direction representing east.


SOUTH

public static final Direction SOUTH
The direction representing south.


WEST

public static final Direction WEST
The direction representing west.

Method Detail

values

public static final Direction[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(Direction c : Direction.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static Direction valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name

clockwise90

public Direction clockwise90()
Returns the direction that is 90 degrees clockwise from the current direction.

Returns:
the direction 90 degrees clockwise from the current direction

counterClockwise90

public Direction counterClockwise90()
Returns the direction that is 90 degrees counter-clockwise from the current direction.

Returns:
the direction 90 degrees counterclockwise from the current direction