vacworld
Class Direction

java.lang.Object
  extended by vacworld.Direction

public class Direction
extends java.lang.Object

A utility class that encapsulates information about compass directions. It includes a constant for each direction as well as two arrays, DELTA_X and DELTA_Y, that can be used to compute coordinates of a position one step in a given direction. For example, to compute the coordinates (northX,northY) of the position directly to the north of (x,y):

 int northX = x + DELTA_X[NORTH];
 int northY = y + DELTA_Y[NORTH];
 


Field Summary
static int[] DELTA_X
          An array for determining the change in X position that would correspond to a step in the direction indexed.
static int[] DELTA_Y
          An array for determining the change in Y position that would correspond to a step in the direction indexed.
static int EAST
           
static int NORTH
           
static int SOUTH
           
static int WEST
           
 
Constructor Summary
Direction()
           
 
Method Summary
static java.lang.String toString(int direction)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH

public static final int NORTH
See Also:
Constant Field Values

EAST

public static final int EAST
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
See Also:
Constant Field Values

WEST

public static final int WEST
See Also:
Constant Field Values

DELTA_X

public static final int[] DELTA_X
An array for determining the change in X position that would correspond to a step in the direction indexed.


DELTA_Y

public static final int[] DELTA_Y
An array for determining the change in Y position that would correspond to a step in the direction indexed.

Constructor Detail

Direction

public Direction()
Method Detail

toString

public static java.lang.String toString(int direction)