darwin.domain
Class Direction

java.lang.Object
  extended bydarwin.domain.Direction

public class Direction
extends java.lang.Object

This class represents compass directions. It is an enumeration of North, South, East and West.


Field Summary
static Direction EAST
          Direction east.
static Direction NORTH
          Direction north.
static Direction SOUTH
          Direction south.
static Direction WEST
          Direction west.
 
Method Summary
 boolean equals(java.lang.Object aObject)
          Override-prevention method.
 java.awt.Point getAdjacentPosition(java.awt.Point aPoint)
          Determine the position that is in this direction of a position.
 int hashCode()
          Override-prevention method.
 Direction leftFrom()
          Determine the Direction that is 90 degrees left from this Direction.
 Direction rightFrom()
          Determine the Direction that is 90 degrees right from this Direction.
 java.lang.String toString()
          Return a String representation of this direction.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EAST

public static final Direction EAST
Direction east.


NORTH

public static final Direction NORTH
Direction north.


SOUTH

public static final Direction SOUTH
Direction south.


WEST

public static final Direction WEST
Direction west.

Method Detail

equals

public final boolean equals(java.lang.Object aObject)
Override-prevention method.


getAdjacentPosition

public java.awt.Point getAdjacentPosition(java.awt.Point aPoint)
Determine the position that is in this direction of a position.

Parameters:
aPoint - a position.
Returns:
the position that is in this direction of aPoint. E.g. if aPoint is (2, 3) and this Direction is SOUTH, the method returns (2, 4).

hashCode

public final int hashCode()
Override-prevention method.


leftFrom

public Direction leftFrom()
Determine the Direction that is 90 degrees left from this Direction.

Returns:
the Direction 90 degrees left from this Direction.

rightFrom

public Direction rightFrom()
Determine the Direction that is 90 degrees right from this Direction.

Returns:
the Direction 90 degrees right from this Direction.

toString

public java.lang.String toString()
Return a String representation of this direction.

Returns:
a String representation of this direction.