#include <iostream> //For console output
#include <windows.h> // WinApi header
using namespace std;
#define EMPTY_CELL 177
#define CURSOR 1
#define TAIL 219
#define NUM 6
class Room {
private:
public:
bool visited();
bool active();
Room(); // Default Constructor
Room(bool visited, bool active); // Overloaded Constructor
Room(const Room& node); // Copy Constructor
Room& operator= (const Room& node); // Operator
~Room(); // Destructor/Destroyer
//Mutators
void setActive (); // Gets the console ready to draw the minesweeper grid
char draw (); // Draws the grid for minesweeper
};
Room::Room() {
bool visited = NULL;
bool active = NULL;
}
Room::Room(bool v, bool a) {
visited = v;
active = a;
}
Room& Room (const Room &node) {
bool visited = node.visited;
bool active = node.active;
}
Room Room::operator=(const Room& node) {
this->visited = node.visited;
this->active = node.active;
return *this;
}
void Room::setActive () {
this->visited = true;
this->active = true;
}
char Room::draw () {
char ch = char (EMPTY_CELL);
if (visited) {
ch = char (TAIL);
}
if (this->active) {
ch = char (CURSOR);
this->active = false;
}
return ch;
}
Room::~Room () {
}
/************************************************************************************************/
#define MIN_COL 2 //minimum size allowed for number of columns
#define MIN_ROW 2 //minimum size allowed for number of rows
#define MIN_DEPTH 2 //minimum size allowed for the depth
#define MAX_COL 12 //maximum size allowed for number of columns
#define MAX_ROW 12 //maximum size allowed for number of rows
#define MAX_DEPTH 12 //maximum size allowed for the depth
#define LEFT_UPPER_CORNER 201
#define VERTICAL_LINE 186
#define HORIZONTAL_LINE 205
#define RIGHT_UPPER_CORNER 187
#define LEFT_LOWER_CORNER 200
#define RIGHT_LOWER_CORNER 188
#define INTERSECTION 206
#define VERTICAL_WITH_RIGHT_TURN 204
#define VERTICAL_WITH_LEFT_TURN 185
#define HORIZONTAL_WITH_DOWN_LINE 203
#define HORIZONTAL_WITH_UP_LINE 202
#define RROW 11;
#define RCOL 11;
#define EMPTY_CELL 177
#define CURSOR 1
#define TAIL 219
#define NUM 6
class Dynamic3DArray {
protected:
int ROW;
int COL;
int DEPTH;
Room** array;
public:
Dynamic3DArray (); // Default Consturtor
Dynamic3DArray (int row, int col, int depth); // Overloaded Constructor
Dynamic3DArray (const Dynamic3DArray& dynamic3DArray); // Copy Constructor
Dynamic3DArray& operator= (const Dynamic3DArray& dynamic3DArray); //Assignment Operator
~Dynamic3DArray (); //Destroyer/Destructor
//Accessors
int getROW (); //Gets the number of rows
int getCOL (); //Gets the number of columns
int getDEPTH (); //Gets the number for the depth
//Mutators
void create (); //Will create a 3Dimentional grid
void destroy (); //Destroys the grid to free memory
void setActive (int x, int y, int z); //Will make the cells visited
bool setDimentions (); //Will set the dimentions of the grid
void resize (int x, int y, int z); //Will change the dimentions of the grid
void print (int depth); //This prints the grid with the depth given by user
void printDimentions (int x, int y, int z); //This prints the overall grid
};
Dynamic3DArray::Dynamic3DArray () {
this-> ROW = 0;
this-> COL = 0;
this-> DEPTH = 0;
array = NULL;
}
void Dynamic3DArray::create () {
array = new Room**[ROW];
for (int r=0; r<ROW; r++); {
array[r] = new Room*[COL];
for (int c=0; c<COL; c++)
array[r][c] = new Room[DEPTH];
}
}
void Dynamic3DArray::destroy () {
for (int r=0; r<ROW; r++) {
for (int c=0; c<COL; c++)
delete [] array [r][c];
delete [] array [r];
}
delete [] array;
}
Dynamic3DArray::Dynamic3DArray (int row, int col, int depth) {
this-> ROW = row;
this-> COL = col;
this-> DEPTH = depth;
create ();
}
Dynamic3DArray::Dynamic3DArray (const Dynamic3DArray& dynamic3DArray) {
this-> ROW = dynamic3DArray.ROW;
this-> COL = dynamic3DArray.COL;
this-> DEPTH = dynamic3DArray.DEPTH;
create ();
}
void Dynamic3DArray::setActive (int x, int y, int z) {
this-> array [x-1][y-1][z-1].setActive ();
}
void Dynamic3DArray::printDimentions (int x, int y, int z) {
cout << " < " << x << "," << y << "," << z << ">" << endl << endl;
}
void Dynamic3DArray::resize (int r, int c, int d) {
Dynamic3DArray temp (*this);
temp = *this;
this-> destroy ();
this-> ROW = r;
this-> COL = c;
this-> DEPTH = d;
this-> create ();
if (temp.ROW<ROW) {
for (int r=0; r<temp.ROW; r++) {
for (int c=0; c<temp.COL; c++) {
for (int d=0; d<temp.DEPTH; d++)
this-> array[r+1][c+1][d+1]=temp.array[r][c][d];
}
}
}
else {
for (int r=0; r<temp.ROW; r++) {
for (int c=0; c<COL; c++) {
for (int d=0; d<DEPTH; d++) {
this->array[r][c][d]=temp.array[r+1][c+1][d+1];
}
}
}
}
}
int Dynamic3DArray::getROW () {
return this-> ROW;
}
int Dynamic3DArray::getCOL () {
return this-> COL;
}
int Dynamic3DArray::getDEPTH () {
return this->DEPTH;
}
Dynamic3DArray::~Dynamic3DArray () {
destroy ();
}
Dynamic3DArray& Dynamic3DArray::operator=(const Dynamic3DArray& dynamic3DArray) {
destroy ();
this->ROW = dynamic3DArray.ROW;
this->COL = dynamic3DArray.COL;
this->DEPTH = dynamic3DArray.DEPTH;
create ();
for (int r=0; r<ROW; r++) {
for (int c=0; c<COL; c++) {
for (int d=0; d<DEPTH; d++)
array[r][c][d]=dynamic3DArray.array[r][c][d];
}
}
return *this;
}
void Dynamic3DArray::print (int depth) {
system ("cls");
cout << char (LEFT_UPPER_CORNER);
for (int r=0; r<ROW; r++) {
cout << char (HORIZONTAL_LINE) << char (HORIZONTAL_WITH_DOWN_LINE);
}
cout << "\b" << char (RIGHT_UPPER_CORNER) << endl;
for (int c=0; c<COL; c++) {
cout << char (VERTICAL_LINE);
for (int r=0; r<ROW; r++) {
cout << array[r][c][depth-1].draw () << char (VERTICAL_LINE);
}
cout << "\b" << char (VERTICAL_WITH_RIGHT_TURN);
if (c< (COL-1)) {
for (int i=0; i<ROW; i++) {
cout << char (HORIZONTAL_LINE) << char (INTERSECTION);
}
cout << "\b" << char (VERTICAL_WITH_LEFT_TURN) << "\n";
}
else {
cout << "\b" << char (LEFT_LOWER_CORNER);
for (int r=0; r<ROW; r++) {
cout << char (HORIZONTAL_LINE) << char (HORIZONTAL_WITH_UP_LINE);
}
}
}
cout << "\b" << char (RIGHT_LOWER_CORNER) << "\n";
}
/************************************************************************************************/
#define MIN_COL 2 //minimum size allowed for number of columns
#define MIN_ROW 2 //minimum size allowed for number of rows
#define MIN_DEPTH 2 //minimum size allowed for the depth
#define MAX_COL 12 //maximum size allowed for number of columns
#define MAX_ROW 12 //maximum size allowed for number of rows
#define MAX_DEPTH 12 //maximum size allowed for the depth
#define LEFT_UPPER_CORNER 201
#define VERTICAL_LINE 186
#define HORIZONTAL_LINE 205
#define RIGHT_UPPER_CORNER 187
#define LEFT_LOWER_CORNER 200
#define RIGHT_LOWER_CORNER 188
#define INTERSECTION 206
#define VERTICAL_WITH_RIGHT_TURN 204
#define VERTICAL_WITH_LEFT_TURN 185
#define HORIZONTAL_WITH_DOWN_LINE 203
#define HORIZONTAL_WITH_UP_LINE 202
#define RROW 11;
#define RCOL 11;
#define NUM 6
class GridActive:Dynamic3DArray {
private:
int x;
int y;
int z;
public:
GridActive::GridActive ():Dynamic3DArray ();
GridActive (int R, int C, int D);
GridActive (const GridActive & grid);
~GridActive ();
//Accessors
bool goNorth ();
bool goSouth ();
bool goWest ();
bool goEast ();
bool goUp ();
bool goDown ();
int getRow ();
int getCol ();
int getDepth ();
int getX ();
int getY ();
int getZ ();
//Mutators
void upsize ();
void downsize ();
void setActive ();
void printDimentions (int x, int y, int z);
void print (int dep);
void GridActive::setActive (int x, int y, int z);
};
GridActive::GridActive ():Dynamic3DArray () {
x=0;
y=0;
z=0;
}
GridActive::GridActive (int R, int C, int D):Dynamic3DArray (R, C, D) {
x=1;
y=1;
z=1;
}
GridActive::~GridActive () {
}
GridActive::GridActive (const GridActive & grid):Dynamic3DArray(grid) {
}
GridActive& GridActive::operator= (const GridActive & grid) {
destroy ();
this->x = grid.x;
this->y = grid.y;
this->z = grid.z;
this->ROW = grid.ROW;
this->COL = grid.COL;
this->DEPTH = grid.DEPTH;
create ();
int*** array = new int**[DEPTH];
for (int r=0; r<ROW; r++) {
for (int c=0; c<COL; c++) {
for (int d=0; d<DEPTH; d++)
array[r][c][d] = grid.array[r][c][d];
}
}
return *this;
}
bool GridActive::goNorth () {
if (y == 1) return false;
y--;
return true;
}
bool GridActive::goSouth () {
if (y == COL) return false;
y++;
return true;
}
bool GridActive::goDown () {
if (z == 1) return false;
z--;
return true;
}
bool GridActive::goUp () {
if (z == DEPTH) return false;
z++;
return true;
}
bool GridActive::goEast () {
if (x == ROW) return false;
x++;
return true;
}
bool GridActive::goWest () {
if (x == 1) return false;
x--;
return true;
}
int GridActive::getRow () {
return ROW;
}
int GridActive::getCol () {
return COL;
}
int GridActive::getDepth () {
return DEPTH;
}
void GridActive::print (int dep) {
Dynamic3DArray::print (dep);
}
int GridActive::getX () {
return x;
}
int GridActive::getY () {
return y;
}
int GridActive::getZ () {
return z;
}
void GridActive::setActive (int x, int y, int z) {
Dynamic3DArray::setActive (x, y, z);
}
void GridActive::printDimentions (int x, int y, int z) {
Dynamic3DArray::printDimentions (x, y, z);
}
void GridActive::upsize() {
if ((ROW< MAX_ROW-2) && (COL<MAX_COL-2) && (DEPTH< MAX_DEPTH-2)) {
resize (this->ROW+2, this->COL+2, this->DEPTH+2);
x++;
y++;
z++;
}
}
void GridActive::downsize () {
if (ROW > MIN_ROW && COL > MIN_COL && DEPTH > MIN_DEPTH &&
this->x != this->y !=1 && this->z !=1 &&
this->x != this->ROW && this->y != this->COL && this->z != DEPTH) {
resize (this->ROW-2, this->COL-2, this->DEPTH-2);
x--;
y--;
z--;
}
}
void printEnd() {
system ("cls");
cout << "XXXXXXXXXXXXXXX XX XX XXX XXXXX XXX XXX XXX XXX XXX XXXXX XXX XXX" << endl;
cout << "XXXXXXXXXXXXXXX XX XX XXXXX XXXXXX XXX XXX XXX XXX XXX XXX XXX XXX XXX" << endl;
cout << " XXX XX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX" << endl;
cout << " XXX XXXXXXXXX XXX XXX XXX XXX XXX XXXXXXX XXXXX XXX XXX XXX XXX" << endl;
cout << " XXX XXXXXXXXX XXXXXXXXX XXX XXX XXX XXXXXXX XXXX XXX XXX XXX XXX" << endl;
cout << " XXX XX XX XXXXXXXXXXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX" << endl;
cout << " XXX XX XX XXX XXX XXX XXXXXX XXX XXX XXX XXX XXX XXX XXX " << endl;
cout << " XXX XX XX XXX XXX XXX XXXXX XXX XXX XXX XXXXX XXXXXX " << endl;
cout << " " << endl;
cout << "XXXXXXXXXX XXXXX XXXXXXXX XXXXXXXX XX X XX XXX XX XXX XX XXXXXXX " << endl;
cout << "XXXXXXXXXX XXX XXX XXXXXXXXX XXX XXXX XX XXX XX XXX XX XXXX XX XXXXX XX " << endl;
cout << "XXX XXX XXX XXX XXX XXX XX XX XXXXX XX XXX XX XX XX XX XXXX " << endl;
cout << "XXXXXX XXX XXX XXX XXX XXX XXX XX XX XXX XXXX XX XX XX XX XXX " << endl;
cout << "XXXXXX XXX XXX XXXXXXXX XXXXXXX XX XXXXXXX XXX XX XX XX XX XXX XXXXX" << endl;
cout << "XXX XXX XXX XXX XXX XXX XX XXXXXXXXX XXX XX XX XX XX XXXX XXX" << endl;
cout << "XXX XXX XXX XXX XXX XXX XXXXXXX XX XXX XXX XX XX XXXXX XXXXXXXXXX " << endl;
cout << "XXX XXXXX XXX XXX XXX XXXXXXX XX XXX XXX XX XX XXXX XXXXXX " << endl;
}
void main () {
HANDLE hConsole;
int k;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for(k = 1; k < 2; k++) {
SetConsoleTextAttribute(hConsole, 26);
char keyPressed;
bool quit = false;
int dX;
int dY;
int dZ;
do {
system("cls");
cout <<endl;
cout <<endl;
cout <<"xxxx___xxxx__xx__xxx____xxx__xxxxxx___xxxxxx___xxx___________xxx__xxxxxx__xxxxxx__xxxxx_____xxxxxx__xxxxxx" << endl;
cout <<"xxxx___xxxx__xx__xxxx___xxx__xxxxxx__xxxxxxxx__xxx___________xxx__xxxxxx__xxxxxx__xxxxxxx___xxxxxx__xxxxxxx"<< endl;
cout <<"xxxxx_xxxxx__xx__xxxx___xxx__xx______xxx__xxx__xxx___________xxx__xx______xx______xx___xxx__xx______xx___xx"<< endl;
cout <<"xxx_xxx_xxx__xx__xxxxx__xxx__xx______xxx________xxx_________xxx___xx______xx______xx___xxx__xx______xx___xx"<< endl;
cout <<"xxx_xxx_xxx__xx__xxx_xx_xxx__xxxxx____xxx_______xxx____x____xxx___xxxxx___xxxxx___xxxxxxx___xxxxx___xxxxxx"<< endl;
cout <<"xxx__x__xxx__xx__xxx__xxxxx__xxxxx______xxx______xxx___x___xxx____xxxxx___xxxxx___xxx_______xxxxx___xxxx"<< endl;
cout <<"xxx_____xxx__xx__xxx__xxxxx__xx___________xxx____xxx__xxx__xxx____xx______xx______xx________xx______xx_xx"<< endl;
cout <<"xxx_____xxx__xx__xxx___xxxx__xx______xxx__xxx_____xxxx___xxxx_____xx______xx______xx________xx______xx__xx"<< endl;
cout <<"xxx_____xxx__xx__xxx____xxx__xxxxxx__xxxxxxxx_____xxx_____xxx_____xxxxxx__xxxxxx__xx________xxxxxx__xx__xx"<< endl;
cout <<"xxx_____xxx__xx__xxx____xxx__xxxxxx___xxxxxx______xxx_____xxx_____xxxxxx__xxxxxx__xx________xxxxxx__xx__xx"<< endl;
cout << endl << endl << endl;
system("pause");
cout <<" You may use the ESC button to quit MINESWEEPER anytime you wish" << endl;
cout <<" The arrow buttons on your keyboard will be used to move your player around" << endl;
cout <<" The buttons < and > will be used to go up and down levels" << endl;
cout <<" The buttons = or - will be used to increse or decrease the size of your game" << endl;
system("pause");
cout << " Enter the number of rows you would like to have" << endl;
cin >> dX;
while (dX > MAX_ROW) {
cout << " Please re-enter the number of rows you would like that is less than your previous entry" << endl;
cin >> dX;
}
while (dX < MIN_ROW) {
cout << " Please re-enter the number of rows you would like that is greater than your previous entry" << endl;
cin >> dX;
}
cout << " Enter the number of columns you would like to have" << endl;
cin >> dY;
while (dY > MAX_COL) {
cout << " Please re-enter the number of columns you would like that is less than your previous entry" << endl;
cin >> dY;
}
while (dY < MIN_COL) {
cout << " Please re-enter the number of columns you would like that is greater than your previous entry" << endl;
cin >> dY;
}
cout << " Enter the depth you would like to have" << endl;
cin >> dZ;
while (dZ > MAX_DEPTH) {
cout << " Please re-enter the depth you would like that is less than your previous entry" << endl;
cin >> dZ;
}
while (dZ < MIN_DEPTH) {
cout << " Please re-enter the depth you would like that is greater than your previous entry" << endl;
cin >> dZ;
}
GridActive myGridActive (dX, dY, dZ);
do{
myGridActive.setActive ( myGridActive.getX(), myGridActive.getY(), myGridActive.getZ());
myGridActive.print (myGridActive.getZ());
myGridActive.printDimensions ( myGridActive.getX(), myGridActive.getY(), myGridActive.getZ() );
myGridActive.printDimensions ( myGridActive.getRow(), myGridActive.getCol(), myGridActive.getDepth() );
keyPressed = toascii ( getch() );
switch (keyPressed)
{
case 27 : quit = true; break;
case 44 : myGridActive.goDown (); break;
case 46 : myGridActive.goUp (); break;
case 61 : myGridActive.upsize (); break;
case 99 : system ("cls"); break;
case 45 : myGridActive.downsize (); break;
case 96 : {
keyPressed = toascii (getch() );
switch (keyPressed)
{
case 72 : myGridActive.goNorth (); break;
case 80 : myGridActive.goSouth (); break;
case 75 : myGridActive.goWest (); break;
case 77 : myGridActive.goEast (); break;
default: break;
}
default: break:
}
}
}
while (!quit);
cout << "\n Would you like to start over? Press any key \n Would you like to quit? Press N ";
keyPressed = getch ();
quit = false;
if (( keyPressed == 'N' ) || (keyPressed == 'n' ))
quit = true;
}
cin.get(); // wait
return 0;
while (!quit);
printEnd();
}
i get the following errors i cannot seem to fix
--------------------Configuration: game101new - Win32 Debug--------------------
Compiling...
game101new.cpp
line 44 : error C2659: '=' : overloaded function as left operand
line 45 : error C2659: '=' : overloaded function as left operand
line 55 : error C2143: syntax error : missing ';' before 'tag::id'
line 55 : error C2501: 'Room' : missing storage-class or type specifiers
line 55 : error C2373: 'Room' : redefinition; different type modifiers
line 49 : see declaration of 'Room'
line 55 : fatal error C1004: unexpected end of file found
Error executing cl.exe.
game101new.exe - 6 error(s), 0 warning(s)