|
||||||||
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
One of 9 possible directions an object can move on a 2D board of squares. Includes the 8 cardinal and intermediate compass directions (N, NE, E, etc.) plus HERE, which means the current square.
Also provides a number of methods that can be called on a Direction object. Modifiers indicate the change involved with moving the given direction on a 2D board of squares. Whether for (row, col) or (x, y), the origin (0,0) is assumed to be the top-left of the board or screen.
Enum Constant Summary | |
---|---|
E
|
|
HERE
|
|
N
|
|
NE
|
|
NW
|
|
S
|
|
SE
|
|
SW
|
|
W
|
Method Summary | |
---|---|
int |
getColModifier()
Returns the X/column change on the screen that is associated with this direction: -1 for W, 0 for N/S, and +1 for E. |
int |
getRowModifier()
Returns the Y/row change on the screen that is associated with this direction: -1 for N, 0 for E/W, and +1 for south. |
int |
getXModifier()
As getColModifier() |
int |
getYModifier()
As getRowModifier() |
Direction |
reverse()
Returns the direction that is the opposite of this one. |
static Direction |
valueOf(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 are declared. |
Methods inherited from class java.lang.Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final Direction N
public static final Direction NE
public static final Direction E
public static final Direction SE
public static final Direction S
public static final Direction SW
public static final Direction W
public static final Direction NW
public static final Direction HERE
Method Detail |
---|
public static Direction[] values()
for (Direction c : Direction.values()) System.out.println(c);
public static Direction valueOf(String name)
name
- the name of the enum constant to be returned.
IllegalArgumentException
- if this enum type has no constant
with the specified name
NullPointerException
- if the argument is nullpublic int getColModifier()
public int getRowModifier()
public int getXModifier()
getColModifier()
public int getYModifier()
getRowModifier()
public Direction reverse()
Direction.NE.reverse() == Direction.SW
.
(The opposite of HERE is still HERE though.)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |