|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Objectjava.lang.Enum<Direction>
battlecode.common.Direction
public enum Direction
This enumeration represents a direction from one MapLocation to another. There is a direction for each of the cardinals (north, south, east, west), and each of diagonals (northwest, southwest, northeast, southeast). There is also NONE, representing no direction, and OMNI, representing all directions.
Since Direction is a Java 1.5 enum, you can use it inswitch
statements, it has all the standard enum methods (valueOf
,
values
, etc.), and you can safely use ==
for
equality tests.
Enum Constant Summary | |
---|---|
EAST
|
|
NONE
No direction. |
|
NORTH
|
|
NORTH_EAST
|
|
NORTH_WEST
|
|
OMNI
All directions. |
|
SOUTH
|
|
SOUTH_EAST
|
|
SOUTH_WEST
|
|
WEST
|
Field Summary | |
---|---|
int |
dx
|
int |
dy
|
Method Summary | |
---|---|
boolean |
isDiagonal()
Determines whether or not this direction is a diagonal one. |
Direction |
opposite()
Computes the direction opposite this one. |
Direction |
rotateLeft()
Computes the direction 45 degrees to the left (counter-clockwise) of this one. |
Direction |
rotateRight()
Computes the direction 45 degrees to the right (clockwise) 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 NORTH
public static final Direction NORTH_EAST
public static final Direction EAST
public static final Direction SOUTH_EAST
public static final Direction SOUTH
public static final Direction SOUTH_WEST
public static final Direction WEST
public static final Direction NORTH_WEST
public static final Direction NONE
public static final Direction OMNI
Field Detail |
---|
public final int dx
public final int dy
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 boolean isDiagonal()
public Direction opposite()
public Direction rotateLeft()
public Direction rotateRight()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |