jurpe.dungeon.crawler
Enum Direction

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

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

Direction helper class. Incapsulates direction info as an integer value.


Enum Constant Summary
NORTH
           
NORTHEAST
           
NORTHWEST
           
SOUTH
           
SOUTHEAST
           
SOUTHWEST
           
 
Method Summary
static Direction fromString(java.lang.String str)
          Get a direction from a string.
static Direction fromValue(short x)
          Return a direction from a given value
static Direction getInverse(Direction d)
          Get the inverse direction (ie: North->South, SouthWest->NorthEast)
static Direction getRandom(java.util.Random rnd)
          Get a random direction
 short getValue()
          Get the value of this direction
 java.lang.String toString()
          To string
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
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

NORTH

public static final Direction NORTH

NORTHEAST

public static final Direction NORTHEAST

SOUTHEAST

public static final Direction SOUTHEAST

SOUTH

public static final Direction SOUTH

SOUTHWEST

public static final Direction SOUTHWEST

NORTHWEST

public static final Direction NORTHWEST
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

getRandom

public static Direction getRandom(java.util.Random rnd)
                           throws JurpeException
Get a random direction

Parameters:
rnd - Random seed
Returns:
New random Direction object
Throws:
JurpeException

fromString

public static Direction fromString(java.lang.String str)
Get a direction from a string. If not recognized, a null will be returned.

Parameters:
str - Can be North,South,NorthEast,NorthWest,SouthEast,SouthWest.
Returns:
A direction from a string

fromValue

public static Direction fromValue(short x)
                           throws JurpeException
Return a direction from a given value

Parameters:
x - 0=N,1=NE,2=SE,3=S,4=SW,5=NW
Returns:
The Direction
Throws:
JurpeException

getInverse

public static Direction getInverse(Direction d)
Get the inverse direction (ie: North->South, SouthWest->NorthEast)

Parameters:
d - Direction to be inverted
Returns:
New direction that is the inverse of d

toString

public java.lang.String toString()
To string

Overrides:
toString in class java.lang.Enum<Direction>

getValue

public short getValue()
Get the value of this direction

Returns:
The value of this direction

Jurpe - Java Universal Role Playing Engine - http://jurpe.sourceforge.net