Im really trying to do this c++ but...

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 22
Reputation: chubbywubba is an unknown quantity at this point 
Solved Threads: 0
chubbywubba's Avatar
chubbywubba chubbywubba is offline Offline
Newbie Poster

Im really trying to do this c++ but...

 
0
  #1
Nov 22nd, 2006
Im really trying to do this c++ stuff and I need someone to really help me. My yahoo is eyestolethis. If someone could please come on yahoo and message me and try to help me that would be great. I have the code already written for the program I created, 3D Minesweeper, I would post it all on here but that really will not help me I need someone I can talk to one on one to do me a favor because my comp is stupid.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Im really trying to do this c++ but...

 
0
  #2
Nov 22nd, 2006
Just post your code here and we might be able to help you (use code tags, indentation, and don't use void main). The mods here don't like it when you post your email address and get it off-site, so don't be suprised if they snip your Yahoo address...

Thanks.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 22
Reputation: chubbywubba is an unknown quantity at this point 
Solved Threads: 0
chubbywubba's Avatar
chubbywubba chubbywubba is offline Offline
Newbie Poster

Re: Im really trying to do this c++ but...

 
0
  #3
Nov 22nd, 2006
this is what i need help with, thereason why i didnt wanna post it is cause i dont want no one stealing my game code and plus as you see its really long, and i mean long. but im at home and i cant drive back to school and i wanted to know if this code works. like are you able to play the game, does some of it come out in color, etc. my comp is stupid and never lets me download stuff to my comp, i have tried downloading many c++ compiliers and it never downloads. so pretty much i just need someone to tell me it works or not. if not if they can help me with the errors, by either telling me or if they fix them but still tell me so i know what i did wrong or show me at least. im trying my hardest to learn this stuff and my advisor through me in a class where normal people would have takin two other c++ courses before this one. i took a java class but she never told this one she put me in was c++ so i pretty much started off with nothing.




  1. //****************************************************************************//
  2. //****************************************************************************//
  3. //**** Program Name: Project1 Minesweeper ****//
  4. //**** File: Minesweeper.cpp ****//
  5. //**** Input Files: created by the user ****//
  6. //**** Output Files: None; output is sent to the terminal screen ****//
  7. //**** Modules Used: conio.h ****//
  8. //**** iostream ****//
  9. //**** Purpose: This program was created to make a 3-Dimensional ****//
  10. //**** Minesweeper, that can be up-sized and down-sized ****//
  11. //**** at anytime. ****//
  12. //****************************************************************************// //
  13. //****************************************************************************//
  14.  
  15. #include <iostream> //For console output
  16. #include <conio.h> //For non-standard screen functions
  17. #include <iostream>
  18. #include <windows.h> // WinApi header
  19.  
  20. using namespace std;
  21.  
  22.  
  23. #define EMPTY_CELL 177
  24. #define CURSOR 1
  25. #define TAIL 219
  26. #define NUM 6
  27.  
  28.  
  29. class Room {
  30.  
  31. private:
  32. bool visited;
  33. bool active;
  34.  
  35. public:
  36. Room(); // Default Constructor
  37. Room(bool vis, bool act); // Overloaded Constructor
  38. Room(const Room& node); // Copy Constructor
  39. Room& operator= (const Room& node); // Operator
  40. ~Room(); // Destructor/Destroyer
  41.  
  42. //Mutators
  43. void setActive (); // Gets console ready to draw minesweeper grid
  44. char draw; // Draws the grid for minesweeper
  45.  
  46. };
  47.  
  48. Room::Room () {
  49. this->visited = false;
  50. this->active = false;
  51. }
  52.  
  53. Room::Room (bool visited, bool active) {
  54. this->visited = visited;
  55. this->active = active;
  56. }
  57.  
  58. Room::Room (const Room& node) {
  59. this->visited = node.visited;
  60. this->active = node.active;
  61. }
  62.  
  63. Room& Room (const Room& node) {
  64. this->visited = node.visited;
  65. this->active = node.active;
  66. return *this;
  67. }
  68.  
  69.  
  70. void Room::setActive () {
  71. this->visited = true;
  72. this->active = true;
  73. }
  74.  
  75.  
  76. char Room::draw () {
  77. char ch = char (EMPTY_CELL);
  78. if (visited) {
  79. ch = char (TAIL);
  80. }
  81. if (this-> active) {
  82. ch = char (CURSOR);
  83. this-> active = false;
  84. }
  85. return ch;
  86. }
  87.  
  88.  
  89. Room::~Room () {
  90.  
  91. }
  92. /*******************************************************************************/
  93. /*******************************************************************************/
  94.  
  95.  
  96. #define LEFT_UPPER_CORNER 201
  97. #define VERTICAL_LINE 186
  98. #define HORIZONTAL_LINE 205
  99. #define RIGHT_UPPER_CORNER 187
  100. #define LEFT_LOWER_CORNER 200
  101. #define RIGHT_LOWER_CORNER 188
  102. #define INTERSECTION 206
  103. #define VERTICAL_WITH_RIGHT_TURN 204
  104. #define VERTICAL_WITH_LEFT_TURN 185
  105. #define HORIZONTAL_WITH_DOWN_LINE 203
  106. #define HORIZONTAL_WITH_UP_LINE 202
  107. #define RROW 11;
  108. #define RCOL 11;
  109.  
  110. class Dynamic3DArray {
  111.  
  112. protected:
  113. int ROW;
  114. int COL;
  115. int DEPTH;
  116. Room *** array;
  117.  
  118. public;
  119. Dynamic3DArray (); // Default Consturtor
  120. Dynamic3DArray (int row, int col, int depth); // Overloaded Con.
  121. Dynamic3DArray (const Dynamic3DArray& dynamic3DArray);
  122. Dynamic3DArray& operator= (const Dynamic3DArray& dynamic3DArray); //Assignment Operator
  123. ~Dynamic3DArray (); //Destroyer/Destructor
  124.  
  125. //Accessors
  126. int getROW (); //Gets the number of rows
  127. int getCOL (); //Gets the number of columns
  128. int getDEPTH (); //Gets the number for the depth
  129.  
  130. //Mutators
  131. void create (); //Will create a 3Dimentional grid
  132. void destroy (); //Destroys the grid to free memory
  133. void setActive (int x, int y, int z); //Will make the cells visited
  134. bool setDimentions (); //Will set the dimentions of the grid
  135. void resize (int x, int y, int z); //change the dimentions of the grid
  136. void print (int depth); //prints the grid with the depth given by user
  137. void printDimentions (intx, int y, int z); //This prints the overall grid
  138. };
  139.  
  140. Dynamic3DArray::Dynamic3DArray () {
  141. this-> ROW = 0;
  142. this-> COL = 0;
  143. this-> DEPTH = 0;
  144. array = NULL;
  145. }
  146.  
  147.  
  148. void Dynamic3DArray::create () {
  149. array = new Room** [ROW];
  150. for (int r=0; r<ROW; r++) {
  151. array[r] = new Room* [COL];
  152. for (int c=0; c<COL; c++)
  153. array[r][c] = new Room[DEPTH];
  154. }
  155. }
  156.  
  157.  
  158. void Dynamic3DArray::destroy () {
  159. for (int r=0; r<Row; r++) {
  160. for (int c=0; c<COL; c++)
  161. delete [] array [r][c];
  162. delete [] array [r];
  163. }
  164. delete [] array;
  165. }
  166.  
  167.  
  168. Dynamic3DArray::Dynamic3DArray (int row, int col, int depth) {
  169. this-> ROW = row;
  170. this-> COL = col;
  171. this-> DEPTH = depth;
  172. create ();
  173. }
  174.  
  175.  
  176. Dynamic3DArray::Dynamic3DArray (const Dynamic3DArray& dynamic3DArray) {
  177. this-> ROW = dynamic3DArray.ROW;
  178. this-> COL = dynamic3DArray.COL;
  179. this-> DEPTH = dynamic3DArray.DEPTH;
  180. create ();
  181. }
  182.  
  183.  
  184. void Dynamic3DArray:: setActive (intx, int y, int z) {
  185. this-> array[x-1][y-1][z-1].setActive ();
  186. }
  187.  
  188.  
  189. void Dynamic3DArray::printDimentions (int x, int y, int z) {
  190. cout << " < " << x << "," << y << "," << z << ">" << endl << endl;
  191. }
  192.  
  193.  
  194. void Dynamic3DArray::resize (int r, int c, int d) {
  195. Dynamic3DArray temp (*this);
  196. temp = *this;
  197. this-> destroy ();
  198. this-> ROW = r;
  199. this-> COL = c;
  200. this-> DEPTH = d;
  201. this-> create ();
  202. if (temp.ROW<ROW) {
  203. for (int r=0; r<temp.ROW; r++) {
  204. for (int c=0; c<temp.COL; c++) {
  205. for (int d=0; d<temp.DEPTH; d++)
  206. this->array[r+1][c+1][d+1]=temp.array[r][c][d];
  207. }
  208. }
  209. }
  210. }
  211. else
  212. for (int r=0; r<ROW; r++) {
  213. for (int c=0; c<COL; c++) {
  214. for (int d=0; d<DEPTH; d++)
  215. this->array[r][c][d]=temp.array[r+1][c+1][d+1];
  216. }
  217. }
  218. }
  219.  
  220. int Dynamic3DArray::getROW () {
  221. return this-> ROW;
  222. }
  223.  
  224. int Dynamic3DArray::getCOL () {
  225. return this-> COL;
  226. }
  227.  
  228. int Dynamic3DArray::getDep () {
  229. return this->DEPTH;
  230. }
  231.  
  232. Dynamic3DArray::~Dynamic3DArray () {
  233. destroy ();
  234. }
  235.  
  236. Dynamic3DArray& Dynamic3DArray::operator=(const Dynamic3DArray& dynamic3DArray) {
  237. destroy ();
  238. this->ROW = dynamic3DArray.ROW;
  239. this->COL = dynamic3DArray.COL;
  240. this->DEPTH = dynamic3DArray.DEPTH;
  241. create ();
  242. for (int r=0; r<ROW; r++) {
  243. for (int c=0; c<COL; c++) {
  244. for (int d=0; d<DEPTH; d++)
  245. array[r][c][d]=dynamic3DArray.array[r][c][d];
  246. }
  247. }
  248. return *this;
  249. }
  250.  
  251. void Dynamic3DArray::print (int depth) {
  252. system ("cls");
  253. cout << char (LEFT_UPPER_CORNER);
  254. for (int r=0; r<ROW; r++) {
  255. cout << char (HORIZONTAL_LINE) << char (HORIZONTAL_WITH_DOWN_LINE);
  256. }
  257. cout << "\b" << char (RIGHT_UPPER_CORNER) << endl;
  258. for (int c=0; c<COL; c++) {
  259. cout << char (VERTICAL_LINE);
  260. for (int r=0; r<ROW; r++) {
  261. cout << array[r][c][depth-1].draw() << char (VERTICAL_LINE);
  262. }
  263. cout << "\b" << char (VERTICAL_WITH_RIGHT_TURN);
  264. if (c< (COL-1)) {
  265. for (int i=0; i<ROW; i++) {
  266. cout << char (HORIZONTAL_LINE) << char (INTERSECTION);
  267. }
  268. cout << "\b" << char (VERTICAL_WITH_LEFT_TURN) << "\n";
  269. }
  270. else {
  271. cout << "\b" << char (LEFT_LOWER_CORNER);
  272. for (int r=0; r<ROW; r++) {
  273. cout << char (HORIZONTAL_LINE) << char (HORIZONTAL_WITH_UP_LINE);
  274. }
  275. }
  276. }
  277. cout << "\b" << char (RIGHT_LOWER_CORNER) << "\n";
  278. }
  279.  
  280. /****************************************************************************************/
  281. /****************************************************************************************/
  282.  
  283.  
  284. #define MIN_COL 2 //minimum size allowed for number of columns
  285. #define MIN_ROW 2 //minimum size allowed for number of rows
  286. #define MIN_DEPTH 2 //minimum size allowed for the depth
  287. #define MAX_COL 12 //maximum size allowed for number of columns
  288. #define MAX_ROW 12 //maximum size allowed for number of rows
  289. #define MAX_DEPTH 12//maximum size allowed for the depth
  290. #define RROW 11;
  291. #define RCOL 11;
  292.  
  293. class GridActive:Dynamic3DArray {
  294.  
  295. private:
  296. int x;
  297. int y;
  298. int z;
  299.  
  300. public:
  301. GridActive ();
  302. GridActive ( int R, int C, int D);
  303. GridActive (const GridActive & grid);
  304. ~GridActive ();
  305.  
  306. //Accessors
  307. bool goNorth ();
  308. bool goSouth ();
  309. bool goWest ();
  310. bool goEast ();
  311. bool goUp ();
  312. bool goDown ();
  313. int getRow ();
  314. int getCol ();
  315. int getDepth ();
  316. int getX ();
  317. int getY ();
  318. int getZ ();
  319.  
  320. //Mutators
  321. void upsize ();
  322. void downsize ();
  323. void setActive ();
  324. void printDimentions (int x, int y, int z);
  325. void print (int dep);
  326.  
  327. };
  328.  
  329. GridActive::GridActive ():Dynamic3DArray () {
  330. x=0;
  331. y=0;
  332. z=0;
  333. }
  334.  
  335. GridActive::GridActive (int R, int C, int D):Dynamic3DArray (R, C, D) {
  336. x=1;
  337. y=1;
  338. z=1;
  339. }
  340.  
  341. GridActive::~GridActive () {
  342.  
  343. }
  344.  
  345. GridActive::GridActive (const GridActive & grid):Dynamic3DArray(grid) {
  346.  
  347. }
  348.  
  349. GridActive& GridActive::operator= (const GridActive & grid) {
  350. destroy ();
  351. this->x = grid.x;
  352. this->y = grid.y;
  353. this->z = grid.z;
  354. this->ROW = grid.ROW;
  355. this->COL = grid.COL;
  356. this->DEPTH = grid.DEPTH;
  357. create ();
  358. for (int r=0; r<ROW; r++) {
  359. for (int c=0;, c<COL; c++) {
  360. for (int d=0; d<DEPTH; d++)
  361. array[r][c][d]=grid.array[r][c][d];
  362. }
  363. }
  364. return *this;
  365. }
  366.  
  367. bool GridActive::goNorth () {
  368. for (y == 1) return false;
  369. y--;
  370. return true;
  371. }
  372.  
  373. bool GridActive::goSouth () {
  374. if (y == COL) return false;
  375. y++;
  376. return true;
  377. }
  378.  
  379. bool GridActive::goDown () {
  380. if (z == 1) return false;
  381. z--;
  382. return true;
  383. }
  384.  
  385. bool GridActive::goUp () {
  386. if (z == DEPTH) return false;
  387. z++;
  388. return true;
  389. }
  390.  
  391. bool GridActive::goEast () {
  392. if (x == ROW) return false;
  393. x++;
  394. return true;
  395. }
  396.  
  397. bool GridActive::goWest () {
  398. if (x == 1) return false;
  399. x--;
  400. return true;
  401. }
  402.  
  403. int GridActive::getROW () {
  404. return ROW;
  405. }
  406.  
  407. int GridActive::getCol () {
  408. return COl;
  409. }
  410.  
  411. int GridActive::getDEPTH () {
  412. return DEPTH;
  413. }
  414.  
  415. void GridActive::print (int dep) {
  416. Dynamic3DArray::print (dep)
  417. }
  418.  
  419. int GridActive::getX () {
  420. return x;
  421. }
  422.  
  423. int GridActive::getY () {
  424. return y;
  425. }
  426.  
  427. int GridActive::getZ () {
  428. return z;
  429. }
  430.  
  431. void GridActive::setActive (int x, int y, int z) {
  432. Dynamic3DArray::setActive (x, y, z);
  433. }
  434.  
  435. void GridActive::printDimentions (int x, int y, int z) {
  436. Dynamic3DArray::printDimentions (x, y, z);
  437. }
  438.  
  439. void GridActive::upsize() {
  440. if ((ROW< MAX_ROW-2) && (COL<MAX_COL-2) && (DEPTH< MAX_DEPTH-2)) {
  441. resize (this->ROW+2, this->COL+2, this->DEPTH+2);
  442. x++;
  443. y++;
  444. z++;
  445. }
  446. }
  447.  
  448. void GridActive::downsize () {
  449. if (ROW>MIN_ROW && COL>MIN_COL && DEPTH>MIN_DEPTH &&
  450. this->x != this->y !=1 && this->z !=1 &&
  451. this->x != this->ROW && this->y != this->COL && this->z !=DEPTH) {
  452. resize (this->ROW-2, this->COL-2, this->DEPTH-2);
  453. x--;
  454. y--;
  455. z--;
  456. }
  457. }
  458.  
  459.  
  460.  
  461.  
  462.  
  463. void printEnd() {
  464. system ("cls");
  465. cout << "XXXXXXXXXXX_XX_____XX_____XXX_____XXXX______XX_XXX____XXX______XXX______XXX____XXXXX_____XXX_____XXX_______" << endl;
  466. cout << "XXXXXXXXXXX_XX_____XX____XXXXX____XXXXX_____XX_XXX___XXX_______XXX____XXX____XXX___XXX___XXX_____XXX_______" << endl;
  467. cout << "_____XX_____XX_____XX___XXX_XXX___XX_XXX____XX_XXX__XXX________XXX__XXX____XXX______XXX__XXX_____XXX_______" << endl;
  468. cout << "_____XX_____XXXXXXXXX__XXX___XXX__XX__XXX___XX_XXXXXXX_________XXXXX_____XXX_________XXX_XXX_____XXX_______" << endl;
  469. cout << "_____XX_____XXXXXXXXX__XXXXXXXXX__XX___XXX__XX_XXXXXXX_________XXXX______XXX_________XXX_XXX_____XXX_______" << endl;
  470. cout << "_____XX_____XX_____XX_XXXXXXXXXXX_XX____XXX_XX_XXX__XXX________XXX_________XXX_____XXX___XXX_____XXX_______" << endl;
  471. cout << "_____XX_____XX_____XX_XXX_____XXX_XX_____XXXXX_XXX___XXX_______XXX__________XXX___XXX_____XXX___XXX________" << endl;
  472. cout << "_____XX_____XX_____XX_XXX_____XXX_XX______XXXX_XXX____XXX______XXX____________XXXXX_________XXXXXX_________" << endl;
  473. cout << "___________________________________________________________________________________________________________" << endl:
  474. cout << "XXXXXXXXX____XXXXX______XXXXXXX_______XXXXXXX____XX__________X_____XX_____XXX_XX_XXX_______XX______XXXXXX__" << endl;
  475. cout << "XXXXXXXXX__XXX___XXX____XXXXXXXX______XX___XXXX__XX_________XXX____XX___XXX___XX_XXXX______XX____XXXX___XX_" << endl;
  476. cout << "XX________XXX_____XXX___XX____XXX_____XX______XX_XX________XXXXX___XX_XXX_____XX_XX_XX_____XX__XXXX________" << endl;
  477. cout << "XXXXX___XXX_________XXX_XX XXX______XX____XXX__XX_______XX__XXX__XXXX_______XX_XX__XX____XX_XX___________" << endl;
  478. cout << "XXXXX___XXX_________XXX_XXXXXXX_______XXXXXX_____XX_______XXXXXXX__XXX________XX_XX___XX___XX_XX______XXXXX" << endl;
  479. cout << "XX________XXX_____XXX___XX__XXX_______XX_________XX______XXXXXXXXX_XXX________XX_XX____XX__XX__XXXX_____XXX" << endl;
  480. cout << "XX_________XXX___XXX____XX___XXX______XX_________XXXXXXX_XX____XXX_XXX________XX_XX_____XXXXX____XXXXXXXXX_" << endl;
  481. cout << "XX__________XXXXX_______XX____XXX_____XX_________XXXXXXX_XX____XXX_XXX________XX_XX______XXXX______XXXXX___" << endl;
  482. }
  483.  
  484.  
  485. void main () {
  486. char keyPressed;
  487. bool quit = false;
  488. int dX;
  489. int dY;
  490. int dZ;
  491. do {
  492. system("cls");
  493. cout <<endl;
  494. cout <<endl;
  495. cout <<"xxxx___xxxx__xx__xxx____xxx__xxxxxx___xxxxxx___xxx___________xxx__xxxxxx__xxxxxx__xxxxx_____xxxxxx__xxxxxx__" << endl;
  496. cout <<"xxxx___xxxx__xx__xxxx___xxx__xxxxxx__xxxxxxxx__xxx___________xxx__xxxxxx__xxxxxx__xxxxxxx___xxxxxx__xxxxxxx_"<< endl;
  497. cout <<"xxxxx_xxxxx__xx__xxxx___xxx__xx______xxx__xxx__xxx___________xxx__xx______xx______xx___xxx__xx______xx___xx_"<< endl;
  498. cout <<"xxx_xxx_xxx__xx__xxxxx__xxx__xx______xxx________xxx_________xxx___xx______xx______xx___xxx__xx______xx___xx_"<< endl;
  499. cout <<"xxx_xxx_xxx__xx__xxx_xx_xxx__xxxxx____xxx_______xxx____x____xxx___xxxxx___xxxxx___xxxxxxx___xxxxx___xxxxxx__"<< endl;
  500. cout <<"xxx__x__xxx__xx__xxx__xxxxx__xxxxx______xxx______xxx___x___xxx____xxxxx___xxxxx___xxx_______xxxxx___xxxx____"<< endl;
  501. cout <<"xxx_____xxx__xx__xxx__xxxxx__xx___________xxx____xxx__xxx__xxx____xx______xx______xx________xx______xx_xx___"<< endl;
  502. cout <<"xxx_____xxx__xx__xxx___xxxx__xx______xxx__xxx_____xxxx___xxxx_____xx______xx______xx________xx______xx__xx__"<< endl;
  503. cout <<"xxx_____xxx__xx__xxx____xxx__xxxxxx__xxxxxxxx_____xxx_____xxx_____xxxxxx__xxxxxx__xx________xxxxxx__xx__xx__"<< endl;
  504. cout <<"xxx_____xxx__xx__xxx____xxx__xxxxxx___xxxxxx______xxx_____xxx_____xxxxxx__xxxxxx__xx________xxxxxx__xx__xx__"<< endl;
  505. cout << endl << endl << endl;
  506. system("pause");
  507. int main() {
  508. HANDLE hConsole;
  509. int k;
  510. hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  511. for(k = 1; k < 2; k++) {
  512. SetConsoleTextAttribute(hConsole, 26);
  513. cout <<"You may use the ESC button to quit MINESWEEPER anytime you wish" << endl;
  514. cout <<"The arrow buttons on your keyboard will be used to move your player around" << endl;
  515. cout <<"The buttons < and > will be used to go up and down levels" << endl;
  516. cout <<"The buttons = or - will be used to increse or decrease the size of your game" << endl;
  517. system("pause");
  518. cout << "Enter the number of rows you would like to have" << endl;
  519. cin >> dX;
  520. while (dX > MAX_ROW) {
  521. cout << "Please re-enter the number of rows you would like that is less than your previous entry" << endl;
  522. cin >> dX;
  523. }
  524. while (dX < MIN_ROW) {
  525. cout << "Please re-enter the number of rows you would like that is greater than your previous entry" << endl;
  526. cin << dX;
  527. }
  528. cout << "Enter the number of columns you would like to have" << endl;
  529. cin >> dY;
  530. while (dY > MAX_COL) {
  531. cout << "Please re-enter the number of columns you would like that is less than your previous entry" << endl;
  532. cin >> dY;
  533. }
  534. while (dY < MIN_COL) {
  535. cout << "Please re-enter the number of columns you would like that is greater than your previous entry" << endl;
  536. cin >> dY;
  537. }
  538. cout << "Enter the depth you would like to have" << endl;
  539. cin >> dZ;
  540. while (dZ > MAX_DEPTH) {
  541. cout << "Please re-enter the depth you would like that is less than your previous entry" << endl;
  542. cin >> dZ;
  543. }
  544. while (dZ < MIN_DEPTH) {
  545. cout << "Please re-enter the depth you would like that is greater than your previous entry" << endl;
  546. cin >> dZ;
  547. }
  548.  
  549. GridActive myGridActive (dX, dY, dZ);
  550. do{
  551. myGridActive.setActive ( myGridActive.getX(), myGridActive.getY(), myGridActive.getZ());
  552. myGridActive.print (myGridActive.getZ());
  553. myGridActive.printDimensions ( myGridActive.getX(), myGridActive.getY(), myGridActive.getZ() );
  554. myGridActive.printDimensions ( myGridActive.getROW(), myGridActive.getCOL(), myGridActive.getDEPTH() );
  555. keyPressed = toascii ( getch() );
  556. switch (keyPressed) {
  557. case 27 : quit = true; break;
  558. case 44 : myGridActive.goDown (); break;
  559. case 46 : myGridActive.goUp (); break;
  560. case 61 : myGridActive.upsize (); break;
  561. case 99 : system ("cls"); break;
  562. case 45 : myGridActive.downsize (); break;
  563. case 96 : {
  564. keyPressed = toascii (getch() );
  565. switch (keyPressed) {
  566. case 72 : myGridActive.goNorth (); break;
  567. case 80 : myGridActive.goSouth (); break;
  568. case 75 : myGridActive.goWest (); break;
  569. case 77 : myGridActive.goEast (); break;
  570. default: break;
  571. }
  572. default: break:
  573. }
  574. }
  575. }
  576. while (!quit);
  577. cout << "\n Would you like to start over? Press any key \n Would you like to quit? Press N ";
  578. keyPressed = getch ();
  579. quit = false;
  580. if (( keyPressed == 'N' ) || (keyPressed == 'n' ))
  581. quit = true;
  582. }
  583. }
  584.  
  585. cin.get(); // wait
  586. return 0;
  587. }
  588. while (!quit);
  589. printEnd();
  590. }
Last edited by chubbywubba; Nov 22nd, 2006 at 10:05 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,853
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 301
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Roasting Maven

Re: Im really trying to do this c++ but...

 
0
  #4
Nov 23rd, 2006
Sorry, doesn't compile:

//Mutators
     void setActive (); // Gets console ready to draw minesweeper grid
     char draw(); // Draws the grid for minesweeper

  1.  
  2. Room *** array;
What are your trying to do here? Create a pointer-to-etc to a room called array? Or are you trying to make an array of pointers-to-etc?

And there's a few typo's in here, marked in red:
 
for (int r=0; r<Row; r++)   //row is undeclared
void Dynamic3DArray:: setActive (intx, int y, int z) //a space 
for (int r=0; r<ROW; r++) { //line 214 redefined

There are also some general error's with your classes, but since this is not my specialty (i like c not ++ ) maybe someone else could inform you.

I don't have enough time to find them all (after this there are still 62..). I strongly suggest that you download a compiler, it's makes debugging a whole lot easier. Which compilers have you allready tried?

regards Niek
Last edited by niek_e; Nov 23rd, 2006 at 3:13 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Im really trying to do this c++ but...

 
0
  #5
Nov 23rd, 2006
thereason why i didnt wanna post it is cause i dont want no one stealing my game code
No comment. :rolleyes:

Inside the definition of Room:
  1. char draw; // Draws the grid for minesweeper
You later go on to define Room::draw(). Perhaps you forgot parentheses in the class definition?


Room& Room (const Room& node) {
     this->visited = node.visited;
     this->active = node.active;
     return *this;
}
Your code is trying to access private members from a foreign class. If you need to, create a function in Room that reads and returns the values of visited and active. Also, why are you using this to modify variables inside its local scope? To modify Room::visited inside Room::Room(), simply use something like:
  1. visited = node.isVisited(); // used isVisited() because visited is private


Little typo:
class Dynamic3DArray {
 
protected:
         int ROW;
     int COL;
     int DEPTH;
     Room *** array;
 

public;
Another error:
void Dynamic3DArray::destroy () {
     for (int r=0; r<Row; r++) { // previously declared as int ROW
A large number of errors that follow are because of the way you declared array in Dynamic3DArray. Niek explained this, so refer to his post on how to fix this.

After reading through your entire code, I have a question: why in the world do you include windows.h ? It's a console app, so there's no reason to have this line in your code. In fact, (correct me if I'm wrong) I didn't even see a need for conio.h.

Hope this helps
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 22
Reputation: chubbywubba is an unknown quantity at this point 
Solved Threads: 0
chubbywubba's Avatar
chubbywubba chubbywubba is offline Offline
Newbie Poster

Re: Im really trying to do this c++ but...

 
0
  #6
Nov 27th, 2006
I put the pointer there to make an array of pointers. What is the correct way to do it?



Inside the definition of Room:
  1. char draw; // Draws the grid for minesweeper
You later go on to define Room::draw(). Perhaps you forgot parentheses in the class definition?


Room& Room (const Room& node) {
     this->visited = node.visited;
     this->active = node.active;
     return *this;
}
Your code is trying to access private members from a foreign class. If you need to, create a function in Room that reads and returns the values of visited and active. Also, why are you using this to modify variables inside its local scope? To modify Room::visited inside Room::Room(), simply use something like:
  1. visited = node.isVisited(); // used isVisited() because visited is private


Little typo:
class Dynamic3DArray {
 
protected:
         int ROW;
     int COL;
     int DEPTH;
     Room *** array;
 
 
public;
Another error:
void Dynamic3DArray::destroy () {
     for (int r=0; r<Row; r++) { // previously declared as int ROW
A large number of errors that follow are because of the way you declared array in Dynamic3DArray. Niek explained this, so refer to his post on how to fix this.

After reading through your entire code, I have a question: why in the world do you include windows.h ? It's a console app, so there's no reason to have this line in your code. In fact, (correct me if I'm wrong) I didn't even see a need for conio.h.

Hope this helps
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Im really trying to do this c++ but...

 
0
  #7
Nov 27th, 2006
After reading through your entire code, I have a question: why in the world do you include windows.h ? It's a console app, so there's no reason to have this line in your code. In fact, (correct me if I'm wrong) I didn't even see a need for conio.h.
My guess is he has declared windows.h for the colour bit? And conio.h to catch input without needing the user to hit return.

Of course that throws out the chance of his code being portable and all. :lol:
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Im really trying to do this c++ but...

 
0
  #8
Nov 27th, 2006
Originally Posted by chubbywubba View Post
I put the pointer there to make an array of pointers. What is the correct way to do it?
I would think you would only need to declare it as Room **array;. I've kind of forgotten what exactly you needed this array for, because you could just declare the number of elements immeditately, or if it has to be dynamic, you could use vectors/linked list.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 22
Reputation: chubbywubba is an unknown quantity at this point 
Solved Threads: 0
chubbywubba's Avatar
chubbywubba chubbywubba is offline Offline
Newbie Poster

Re: Im really trying to do this c++ but...

 
0
  #9
Nov 28th, 2006
I did that and it has seemed to fix those errors, thank you. But there one error i getting now like 15 times in my program. this is the error

error C2659: '=' : overloaded function as left operand

Thats for this line this->visited= false; .
That little piece of code is within the Room Class part where all of that same error is. And it is all the this-> (active or visited) = (something) all have that same error. Its lines 73, 74, 79, 80, etc.

Originally Posted by joeprogrammer View Post
I would think you would only need to declare it as Room **array;. I've kind of forgotten what exactly you needed this array for, because you could just declare the number of elements immeditately, or if it has to be dynamic, you could use vectors/linked list.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Im really trying to do this c++ but...

 
0
  #10
Nov 28th, 2006
Originally Posted by chubbywubba View Post
I did that and it has seemed to fix those errors, thank you. But there one error i getting now like 15 times in my program. this is the error

error C2659: '=' : overloaded function as left operand

Thats for this line this->visited= false; .
That little piece of code is within the Room Class part where all of that same error is. And it is all the this-> (active or visited) = (something) all have that same error. Its lines 73, 74, 79, 80, etc.
There's no need to use this->. Since these functions are inside Room, they are in scope. To access variables that are in the same object as the function, you can simply use:
  1. visited=false;

I see no reason why you continue to prefix these variables with this->. Remove all references of this-> in front of local variables, and the errors should go away.

Hope this helps
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC