ptft
Class Direction

java.lang.Object
  extended byptft.Direction

public final class Direction
extends java.lang.Object

This final class with a private constructor is used instead of final statics to provide type safety. (In C this would be done with an enum typedef.)


Field Summary
static Direction E
          East
static Direction N
          North
static Direction NE
          North-East
static Direction NW
          North-West
static Direction S
          South
static Direction SE
          South-East
static Direction SW
          South-West
static Direction W
          West
 
Method Summary
static Direction next(Direction d)
          Enumerates directions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N

public static final Direction N
North


S

public static final Direction S
South


W

public static final Direction W
West


E

public static final Direction E
East


NW

public static final Direction NW
North-West


NE

public static final Direction NE
North-East


SW

public static final Direction SW
South-West


SE

public static final Direction SE
South-East

Method Detail

next

public static Direction next(Direction d)
Enumerates directions. To enumerate all directions, pass any direction in and keep on calling this method until you get back to where you started from.

Parameters:
d - a place to start
Returns:
directions going around in a circle in the following order:
NW, N, NE, E, SE, S, SW, W, NW