|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Object java.lang.Enum<Direction> Direction
public enum Direction
Cardinal direction on a grid.
Enum Constant Summary | |
---|---|
EAST
|
|
NORTH
|
|
SOUTH
|
|
WEST
|
Method Summary | |
---|---|
java.awt.Point |
forward(java.awt.Point p)
The point one step forward in this direction. |
abstract java.awt.Point |
forward(java.awt.Point p,
int n)
The point n steps forward in this direction. |
static Direction |
fromTo(java.awt.Point a,
java.awt.Point b)
Returns the larger direction from a to b, favoring the vertical. |
boolean |
isHorizontal()
True for East and West |
boolean |
isVertical()
True for North and South |
abstract Direction |
left()
The direction 90-degrees to the left. |
int |
numTurns(Direction d)
The number of turns needed to reach direction d from this direction. |
abstract Direction |
opposite()
Returns the direction 180 degrees from this one. |
static Direction |
random()
Uniformly distributed random direction. |
abstract Direction |
right()
The direction 90-degrees to the right. |
abstract int |
toInt()
Returns a number between 0 and 3: EAST = 0, NORTH = 1, ... |
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 |
---|
public static final Direction NORTH
public static final Direction WEST
public static final Direction SOUTH
public static final Direction EAST
Method Detail |
---|
public static final Direction[] values()
for(Direction c : Direction.values()) System.out.println(c);
public static Direction valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified namepublic static Direction random()
public abstract Direction left()
public abstract Direction right()
public boolean isHorizontal()
public boolean isVertical()
public int numTurns(Direction d)
public static Direction fromTo(java.awt.Point a, java.awt.Point b)
public abstract Direction opposite()
public java.awt.Point forward(java.awt.Point p)
public abstract java.awt.Point forward(java.awt.Point p, int n)
public abstract int toInt()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |