sofia.micro.jeroo
Enum CompassDirection

java.lang.Object
  extended by java.lang.Enum<CompassDirection>
      extended by sofia.micro.jeroo.CompassDirection
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<CompassDirection>

public enum CompassDirection
extends java.lang.Enum<CompassDirection>

Represents the four cardinal directions of the compass.

Version:
$Date: 2012/08/06 11:13 $
Author:
Stephen Edwards, Last changed by $Author: edwards $

Enum Constant Summary
EAST
          Facing right.
NORTH
          Facing up.
SOUTH
          Facing down.
WEST
          Facing left.
 
Method Summary
abstract  android.graphics.Point offset()
          Get the offset (in terms of a change in x-coordinate and y-coordinate) of the cell one cell away in this direction.
abstract  CompassDirection turn(RelativeDirection where)
          Get the new compass direction by turning a relative amount from the current compass direction.
static CompassDirection valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static CompassDirection[] 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

EAST

public static final CompassDirection EAST
Facing right.


SOUTH

public static final CompassDirection SOUTH
Facing down.


WEST

public static final CompassDirection WEST
Facing left.


NORTH

public static final CompassDirection NORTH
Facing up.

Method Detail

values

public static CompassDirection[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (CompassDirection c : CompassDirection.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static CompassDirection valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

turn

public abstract CompassDirection turn(RelativeDirection where)
Get the new compass direction by turning a relative amount from the current compass direction. If the specified direction is either AHEAD or HERE, this method returns the current direction unchanged.

Parameters:
where - The direction to turn (LEFT or RIGHT).
Returns:
The compass direction that is either LEFT or RIGHT of this compass direction, depending on where you are turning.

offset

public abstract android.graphics.Point offset()
Get the offset (in terms of a change in x-coordinate and y-coordinate) of the cell one cell away in this direction. The x and y coordinates are returned as a Point, where each coordinate is either 1, 0, or -1.

Returns:
The offset needed to move one cell in this direction from an existing location.


Greenfoot homepage