// ****** class Display // ****** // ****** Object of class Display stores characters and the (X,Y) // ****** integer pair associated with character and displays // ****** this data on a two dimemsional grid // ********************************************************************** // ****** The following defines allow a programmer using class Display // ****** to select what type of clear screen operation that is desired. // ****** To select the appropriate clear screen operaton, comment out // ****** the two types not desired and remove the comments on the one // ****** desired. //#define _UNIVERSAL_CLEARSCREEN #define _UNIX_CLEARSCREEN //#define _DOS_CLEARSCREEN // ****** These pre-compiler instructions prevent class Display ******* // ****** from being compiled more than once, which can shorten ******* // ****** the time necessary for compilation of a project using ******* // ****** class Display. ******* // ****** #ifndef _DISPLAY #define _DISPLAY #include #include #include #include #include "position.h" using namespace std; // ****** Struct Row is use to create a two dimentional array for ***** // ****** class Display. ***** // ****** struct Row { int * col; }; // ********************************************************************** class Display { public: Display(); // ****** default constructor; creates an object that supports **** // ****** a display grid of 60 characters across by 30 down **** // ****** (0,0) is in the lower left hand corner. **** Display(int initMaxX, int initMaxY); // ****** constructor that allows the program to set the width **** // ****** of the display grid; the first argument is the **** // ****** across value, the second argument is the down value **** // ****** (0,0) is in the lower left hand corner. **** ~Display(); // ****** distructor; safely removes dynamic variables when ***** // ****** a display object moves out of scope; automatically ***** // ****** called, but can be specifically called if necessary ***** void Load(Position location); // ****** when called, loads the symbol to display and where ***** // ****** along in the grid to display it via the (x,y) ***** // ****** integer pair information; does not store data about ***** // ****** symbols when the (x,y) pair is out of bounds ***** void Show(); // ****** when called, displays all stored symbols in their ***** // ****** given locations, then deletes all information from ***** // ****** storage; (0,0) is in the lower left hand corner. ***** private: Row *items; int maxX, maxY; }; #endif