|
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Objectjava.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.
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. |
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'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 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 final 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 namepublic int getRowModifier()
public int getColModifier()
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 |