// FILE: maze.h -- A two-dimensional text-based maze object // BY: John Zelle // A Maze is an abstraction of a two-dimensional table of characters, where // '*' and '.' have special meaning. '*' indicates a wall in the maze, and // '.' indicates an open cell. Open cells may be filled with any character // Walls are not over-writable. Rows and columns in the maze are indexed // starting at 1. // NOTATION: VALID_POS(r,c) == ( 1 <= r <= max_row() // && 1 <= c <= max_col() ) const int MAX_MAZE_DIM = 25; // Largest maze may have this many rows and cols. class Maze { public: //===================> Public <========================== //================> constructors <================================= Maze(); // POST: This 7 x 7 maze has been created Maze(int rows, int cols); // POST: this rows x cols maze has been created. //================> member functions <============================ int max_row() const; // POST: FCTVAL == maximum valid row index in this maze int max_col() const; // POST: FCTVAL == maximum valid column index in this maze int is_open(int row, int col) const; // PRE: VALID_POS(row, col) // POST: FCTVAL == position (row,col) of this maze is open void mark(int row, int col, char marker); // PRE: VALID_POS(row, col) // && is_open(row, col) // && ASSIGNED(marker) // POST: position (row, col) contains marker void unmark(int row, int col); // PRE: VALID_POS(row, col) && // _map[row][col] != '*' // POST: is_open(row, col) //=======================> friend functions <======================= friend ostream& operator<<(ostream& stream, Maze m); // POST: this maze has been written to stream friend istream& operator>>(istream& stream, Maze& m); // POST: this maze has been read from stream private: //=======================> Private <================================ int _max_row; int _max_col; char _map[MAX_MAZE_DIM+1][MAX_MAZE_DIM+1]; };