The SimpleCxxLib package


#include "direction.h"

This file exports an enumerated type called Direction 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
directionToString(dir) Returns the name of the direction as a string.
leftFrom(dir) Returns the direction that is to the left of the argument.
opposite(dir) Returns the direction that is opposite to the argument.
rightFrom(dir) Returns the direction that is to the right of the argument.

Type detail


enum Direction { NORTH, EAST, SOUTH, WEST };
This enumerated type is used to represent the four compass directions.

Function detail


Direction leftFrom(Direction dir);
Returns the direction that is to the left of the argument.

Usage:

Direction newdir = leftFrom(dir);

Direction rightFrom(Direction dir);
Returns the direction that is to the right of the argument.

Usage:

Direction newdir = rightFrom(dir);

Direction opposite(Direction dir);
Returns the direction that is opposite to the argument.

Usage:

Direction newdir = opposite(dir);

string directionToString(Direction dir);
Returns the name of the direction as a string.

Usage:

string str = directionToString(dir);