direction.hDirection
whose elements are the four compass points: NORTH,
EAST, SOUTH, and WEST.
| Type | |
| Direction | This enumerated type is used to represent the four compass directions. |
| Functions | |
| leftFrom(dir) | Returns the direction that is to the left of the argument. |
| rightFrom(dir) | Returns the direction that is to the right of the argument. |
| opposite(dir) | Returns the direction that is opposite to the argument. |
| directionToString(dir) | Returns the name of the direction as a string. |
enum Direction { NORTH, EAST, SOUTH, WEST };
Direction leftFrom(Direction dir);
Usage:
Direction newdir = leftFrom(dir);
Direction rightFrom(Direction dir);
Usage:
Direction newdir = rightFrom(dir);
Direction opposite(Direction dir);
Usage:
Direction newdir = opposite(dir);
string directionToString(Direction dir);
Usage:
string str = directionToString(dir);