Class Position

java.lang.Object
  extended by Position

public class Position
extends Object

A Position is an (x,y) coordinate in the World, much like the Positions for the maze program.


Field Summary
static int EAST
          The East compass point.
static int NORTH
          The North compass point.
static int SOUTH
          The South compass point.
static int WEST
          The West compass point.
 
Constructor Summary
Position(int x, int y)
          Create a new position for the given x and y coordinates.
 
Method Summary
 Position getAdjacent(int direction)
          Return a new position that is in one of the four compass directions from this.
 int getX()
          Return the x coordinate for the position.
 int getY()
          Return the y coordinate for the position.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORTH

public static final int NORTH
The North compass point.

See Also:
Constant Field Values

EAST

public static final int EAST
The East compass point.

See Also:
Constant Field Values

SOUTH

public static final int SOUTH
The South compass point.

See Also:
Constant Field Values

WEST

public static final int WEST
The West compass point.

See Also:
Constant Field Values
Constructor Detail

Position

public Position(int x,
                int y)
Create a new position for the given x and y coordinates.

Method Detail

getX

public int getX()
Return the x coordinate for the position.


getY

public int getY()
Return the y coordinate for the position.


toString

public String toString()
Overrides:
toString in class Object

getAdjacent

public Position getAdjacent(int direction)
Return a new position that is in one of the four compass directions from this.