Can I recive some feedback with my c++ program?

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

Join Date: Dec 2008
Posts: 1,151
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 145
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Can I recive some feedback with my c++ program?

 
0
  #1
Dec 8th, 2008
The program i made below is a c++ program. All I ask for is some feedback of my program. This program has a menu of option, but I have only implemented option 1,2,3,7thus far. So here is the code.

  1. #include<iostream>
  2. #include<ctime>
  3. #include<cstdlib>
  4. #include<cmath>
  5. #include<string>
  6. using namespace std;
  7. void MemoryMatchingGame();//The matching game;
  8. const int numberOfCards = 16;//Needed for MemoryMatching game;
  9. void shuffle(int [], int);//Needed for MemoryMatching game;
  10. void displayBoard(const int [], int [], int, int, int);//Needed for MemoryMatching game;
  11. void clearScreen();//Needed for MemoryMatching game;
  12. bool checkGameStatus(const int [], int);//Needed for MemoryMatching game;
  13. void menu();//The main menu;
  14. void NUMBERgame();//The number guessing game;
  15. void Rock_Paper_Scissors();//The rock-paper-scissors game;
  16. void Choices();//Includes menu function with user choice needed;
  17. int main(){
  18.  
  19. //Declare/ Initialize variables;
  20. int pick;
  21.  
  22. //Dunction displays menu, and inputs;
  23. Choices();
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. }
  38. void Choices()
  39. { int pick;
  40. menu();
  41. cout<<"Which option would you like to choose: ";
  42. cin>>pick;
  43. cout<<endl;
  44. while((pick<1) || (pick>7))
  45. {
  46. cout<<"Invalid input. Please input a correct response"<<endl;
  47. cin>>pick;
  48. }
  49. switch(pick)
  50. { menu();
  51. cout<<"Which option would you like to choose: ";
  52. cin>>pick;
  53. while((pick<1) || (pick>7))
  54. {
  55. cout<<"Invalid input. Please input a correct response"<<endl;
  56. cin>>pick;
  57. }
  58. case 1: MemoryMatchingGame();
  59. break;
  60. case 2: NUMBERgame();
  61. break;
  62. case 3: Rock_Paper_Scissors();
  63. break;
  64. case 7: exit(1);
  65. break;
  66. }
  67. }
  68. void menu()
  69. {
  70. cout<<"IN THIS MENU YOU HAVE MULTIPLE CHOICES OF GAMES AND APPLICATIONS"<<endl;
  71. cout<<"CHOOSE THE TYPE OF GAME/APPLICATION YOU WANT TO PLAY/PICK."<<endl;
  72. cout<<"AFTER YOUR CHOICE, A DESCRIPTION OF THE GAME WILL POP UP"<<endl;
  73. cout<<"IF YOU WANT TO CONTINUE TO PLAY THE GAME AFTER READING THE DESCRIPTION, THEN FOLLOW DIRECTION FROM THERE"<<endl;
  74. cout<<"!!HAVE FUN!!"<<endl<<endl;
  75. cout<<"1) THE MATCHING GAME "<<endl;
  76. cout<<"2) THE NUMBER GUESSING GAME "<<endl;
  77. cout<<"3) ROCK-PAPER-SICOSSORS GAME"<<endl;
  78. cout<<"4) BLACKJACK"<<endl;
  79. cout<<"5) POKER "<<endl;
  80. cout<<"6) CALCULATOR "<<endl;
  81. cout<<"7) Exit program :( "<<endl;
  82.  
  83. return;
  84. }
  85. void NUMBERgame()
  86. {
  87. //Declare variable/initialize
  88. char play;
  89. int choice1,count(0),choice2;
  90. //Seed random generator;
  91. srand(time(NULL));
  92. //Goal number
  93. int goal=rand()%250+1;
  94. //Displays the description of the game;
  95. cout<<"In this game a number is randomly generated from the range of 1-250. "<<endl;
  96. cout<<"The object of this game is for you to guess the random number. "<<endl;
  97. cout<<"There will be a guide : saying your guess is too high or low. "<<endl;
  98. cout<<"So is this your style of choice?(y/n) "<<endl;
  99. //Input choice;
  100. cin>>play;
  101. cout<<endl;
  102. if(play=='n'||'N')
  103. { cout<<"1) Main Menu "<<endl<<"2) Exit program"<<endl;
  104. cin>>choice1;
  105. cout<<endl;
  106. if(choice1==1)
  107. Choices();
  108. else if(choice1==2)
  109. exit(1);
  110. else while(choice1!=1 && choice1!=2)
  111. { cout<<"Invalid response. Please input a correct response"<<endl;
  112. cin>>choice1;
  113. }
  114. }
  115.  
  116.  
  117. while(play!='y' && play!='n' && play!='Y' && play!='N')
  118. { cout<<"Your input is invalid. Please try again with valid input "<<endl;
  119. cin>>play;
  120. }
  121. if(play=='N'||play=='n')
  122. exit(1);
  123. while(play=='Y' ||play=='y')
  124. { //Input your first guess
  125. cout<<"What is your guess number? : ";
  126. cin>>choice1,choice2;
  127. cout<<endl;
  128. //Keeps track of the number of guesses;
  129. count++;
  130. //check if the guess number is correct;
  131. if(choice1==goal)
  132. { cout<<"Very nice, You have won! "<<endl<<endl;
  133. cout<<"It took you "<<count<<" times to guess the correct number"<<endl<<endl;
  134. cout<<"1) Go to main menu "<<endl;
  135. cout<<"2) Exit Program "<<endl;
  136. cin>>choice2;
  137. if(choice2==2)
  138. exit(1);
  139. if(choice2==1)
  140. { cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
  141. menu();
  142. }
  143. else if(choice2!=1 || choice2!=2)
  144. { cout<<endl<<endl<<"Invalid input. Please input correct number"<<endl;
  145. cin>>choice2;
  146. }
  147.  
  148. }
  149. else if(choice1>goal)
  150. cout<<" Your guess number is too high "<<endl;
  151. else if(choice1<goal)
  152. cout<<" Your guess number is too low "<<endl;
  153.  
  154. }
  155. }
  156. void MemoryMatchingGame()
  157. {
  158. //number of cards in the deck is set to 16
  159.  
  160.  
  161.  
  162. //cards is the array that holds the 16 cards of the deck.
  163. //Shown below is some arbitrary arrangement of cards on the table
  164. int cards[numberOfCards] = {1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8};
  165.  
  166. //cardStatus is the array that holds the information on which cards are face up/face down.
  167. int cardStatus[numberOfCards];
  168.  
  169. //keeps track of number of guesses taken by the player to complete the game.
  170. int guess = 0;
  171.  
  172. //initialize the cardStatus array to all cards face down on the table(integer 0).
  173. for(int i = 0; i < numberOfCards-1; i++)
  174. cardStatus[i]=0;
  175.  
  176. //shuffle the deck before the game begins.
  177. shuffle(cards,numberOfCards);
  178.  
  179. //Ask user if he wants to play the game and if so which cards to turn face up.
  180. //integer coordinates to hold user's choices of cards to flip face up.
  181. int x1, y1, x2, y2,option;
  182. char response;
  183. cout<<"THIS IS A GAME OF MATCHING NUMBER 1-8. THIS GAME TESTS YOUR MEMORY."<<endl;
  184. cout<<"YOU WILL BE USING CORDINATE TO INPUT YOUR GUESSES "<<endl;
  185. cout<<"SO THE QUESTION IS : DO YOU WANT TO PLAY THIS GAME? (y/n)"<<endl;
  186. cin >> response;
  187. if(response=='N' || response=='n')
  188. {
  189. cout<<"1) Main menu "<<endl<<"2) Exit program "<<endl;
  190. cin>>guess;
  191. if(guess==1)
  192. Choices();
  193. else if(guess==2)
  194. exit(1);
  195. else while(guess<1||guess>2)
  196. { cout<<"Invalid input. Please input a correct response "<<endl;
  197. cin>>guess;
  198. }
  199. }
  200. while(response == 'y' || response == 'Y')
  201. {
  202. //display the current board on the screen.
  203. displayBoard(cards, cardStatus, numberOfCards, -1, -1);
  204. guess++;
  205. do
  206. {
  207. //Which cards to turn face up
  208. cout << "\nEnter your guess (2 integers between 1 and 4 separated by a space).\n\nCoordinate One (x y): ";
  209. cin >> x1 >> y1;
  210. cout <<"Coordinate Two (x y): ";
  211. cin >> x2 >> y2;
  212. }while( !((x1 >= 1 && x1 <=4) && (y1 >= 1 && y1 <=4) && (x2 >= 1 && x2 <=4) && (y2 >= 1 && y2 <=4)) );
  213. //display the currrent board with the chosen cards flipped face up.
  214. displayBoard(cards, cardStatus, numberOfCards, (x1-1)*4+y1-1, (x2-1)*4+y2-1);
  215. //check if game is over! (If all cards have been flipped face up)
  216. //print out congratulatory note to the player and tell him/her how many guesses were used.
  217. if(checkGameStatus(cardStatus, numberOfCards))
  218. {
  219. cout << "Congrats! You took " << guess << " guesses!\n";
  220. cout<<" 1) Play this game"<<endl<<"2) Go to main menu"<<endl<<"3) Exit program "<<endl;
  221. cin>>option;
  222. while(option!=1 || option!=2 || option!=3)
  223. { cout<<"Invalid input. Please input a correct response"<<endl;
  224. cin>>option;
  225. cout<<endl;
  226. }
  227. if(option==3)
  228. exit(1);
  229. else if(option==2)
  230. { menu();
  231. break;
  232. }
  233. else if(option==1)
  234. { MemoryMatchingGame();
  235. break;
  236. }
  237. }
  238. //If game is not over ask if the player wants to continue the game
  239. do
  240. {
  241. cout << "\nContinue Game (y/n): ";
  242. cin >> response;
  243. if(response=='n')
  244. { cout<<endl<<"1) Main Menu"<<endl<<"2) Exit Program"<<endl;
  245. cin>>option;
  246. cout<<endl;
  247. if(option==1)
  248. Choices();
  249. else if(option==2)
  250. exit(1);
  251. else while(option!=1 || option!=2)
  252. { cout<<"Invalid response. Please input a correct response"<<endl;
  253. cin>>option;
  254. cout<<endl;
  255. }
  256. }
  257. } while((response != 'y') && (response != 'Y') && (response != 'n') && (response != 'N'));
  258. //clear the old screen off the board
  259. clearScreen();
  260. }
  261. return;
  262. }
  263. /*
  264. shuffle is a function which accepts an int array of some size n and shuffles them by repeatedly selecting two cards at random
  265. and swapping them for some number of times (say 50 times).
  266. */
  267. void shuffle(int arr[], int n)
  268. {
  269. srand(time(0));
  270. int numberOfShuffles = 50;
  271. for(int i = 1; i <= numberOfShuffles; i++)
  272. {
  273. int a = rand()%n;
  274. int b = rand()%n;
  275. int temp = arr[a];
  276. arr[a] = arr[b];
  277. arr[b] = temp;
  278. }
  279. return;
  280. }
  281.  
  282. /*
  283. displayBoard is a function which accepts 5 parameters:
  284. Parameter 1: Array 1 is the actual board (const modified)
  285. Parameter 2: Array 2 is the array which holds information about whether the cards are faceup/facedown
  286. Parameter 3: int - the size of both these arrays
  287. Parameter 4: int - the first index choice of the user of the array Array1 which should be flipped faceup
  288. Parameter 5: int - the index of the array Array1 which should be flipped faceup
  289. selection
  290. */
  291. void displayBoard(const int arr[], int status[], int n, int loc1, int loc2)
  292. {
  293. cout << "\n 1 2 3 4\n" << endl;
  294. for(int i = 0; i <= n-1; i++)
  295. {
  296. if(i%4 == 0)
  297. {
  298. cout << (i+1)/4 + 1 << " ";
  299. }
  300. if (i == loc1) cout << arr[loc1] << " ";
  301. else if (status[i] == 1) cout << arr[i] << " ";
  302. else if (i == loc2) cout << arr[loc2] << " ";
  303. else cout << "*" << " ";
  304. if((i+1)%4 == 0) cout << "\n\n";
  305. }
  306. if((loc1 != loc2) && (arr[loc1] == arr[loc2]))
  307. {
  308. status[loc1] = 1;
  309. status[loc2] = 1;
  310. }
  311. return;
  312. }
  313.  
  314. /*
  315. clearScreen is a function which prints some number of new lines (say, 100 new lines) on the screen. This function hides the cards
  316. that have been temporarily placed faceup by forcing the old board off the screen.
  317. */
  318. void clearScreen()
  319. {
  320. for(int i=1; i <=100; i++)
  321. cout << "\n";
  322. return;
  323. }
  324.  
  325. /*
  326. checkGameStatus is a function which accepts the array which holds the information about which cards are
  327. faceup/facedown and its size. It returns a boolean value which correponds to whether the game is over.
  328. Clearly, the game is over when every card has been idenitified by the player and is faceup.
  329. */
  330. bool checkGameStatus(const int status[], int n)
  331. {
  332. int count = 0;
  333. for (int i=0; i <= n-1; i++)
  334. {
  335. count+=status[i];
  336. }
  337. return (count == n);
  338. }
  339.  
  340. void Rock_Paper_Scissors()
  341. { // Declare/Initialize variables;
  342. char choice,pick;
  343. int compChoice,random,playerCount(0),compCount(0), option;
  344. //Seed random generator;
  345. srand(time(0));
  346.  
  347. //This is the description of the game;
  348. cout<<"THIS IS THE TRADITIONAL GAME OF ROCK-PAPER-SCISSORS"<<endl;
  349. cout<<"THE RULES OF THIS GAME ARE THE FOLLOWING: "<<endl<<endl;
  350. cout<<"A) THIS GAME WILL BE THE BEST OUT 5."<<endl;
  351. cout<<"B) ROCK BEATS SCISSORS, BUT LOOSES AGAINST PAPER"<<endl;
  352. cout<<"C) SCISSORS BEATS PAPER, BUT LOOSES AGAINST ROCK"<<endl;
  353. cout<<"D) PAPER BEATS ROCK, BUT LOOSES AGAINST ROCK"<<endl<<endl;
  354. cout<<"WILL THIS GAME BE YOUR FANCY?(y-n)"<<endl;
  355. cin>>choice;
  356. do{
  357. while(choice!='y' && choice!='n' && choice!='Y' && choice!='N')
  358. { cout<<"Your input is invalid. Please try again with valid input "<<endl;
  359. cin>>choice;
  360. }
  361. if(choice=='n'||choice=='N')
  362. Choices();
  363.  
  364. else if(choice=='y' || choice == 'Y')
  365. {
  366. cout<<"Which object would you like to pick: r-for rock, p-for paper,s-for scissors"<<endl;
  367. cin>>pick;
  368. cout<<endl;
  369.  
  370. if(pick!='r'&& pick!='p'&& pick!='s')
  371. {
  372. cout<<"Invalid input. Please input a valid response. "<<endl;
  373. cin>>pick;
  374. cout<<endl;
  375. }
  376. if(pick=='r')
  377. { cout<<"You picked |Rock|"<<endl;
  378. compChoice= rand()%3+1;
  379.  
  380. if(compChoice==1)//1 is represented as rock
  381. cout<<"The computer choose |rock| "<<endl<<"So this round is a tie. Nobody wins "<<endl;
  382.  
  383. else if(compChoice==2)//2 represents paper.
  384. { cout<<"The computer choose |Paper| "<<endl;
  385. compCount++;
  386. if(compCount==3)//Checks if the computer wins
  387. { cout<<"The computer won this round and the game!"<<endl<<endl;
  388. cout<<"1) Play this game"<<endl<<"2) Go to the main menu"<<endl<<"3) Exit program"<<endl;
  389. cin>>option;
  390.  
  391. if(option==3)
  392. exit(1);
  393. else if(option==2)
  394. Choices();
  395. else if(option==1)
  396. Rock_Paper_Scissors();
  397. else while((option<1)||(option>3))
  398. { cout<<"Invalid input. Please input a valid response"<<endl;
  399. cin>>option;
  400. }
  401. }
  402. cout<<"The computer wins this round"<<endl<<endl;
  403. }
  404. else if(compChoice==3)//3 represents scissors.
  405. { playerCount++;
  406. cout<<"The computer choose |Scissors| "<<endl;
  407. cout<<"You win this round"<<endl<<endl;
  408. if(playerCount==3)
  409. { cout<<"You won this game!"<<endl<<endl;
  410. cout<<"1) Play this game"<<endl<<"2) Go to the main menu"<<endl<<"3) Exit program"<<endl;
  411. cin>>option;
  412.  
  413. if(option==3)
  414. exit(1);
  415. else if(option==2)
  416. Choices();
  417. else if(option==1)
  418. Rock_Paper_Scissors();
  419. else while((option<1)||(option>3))
  420. { cout<<"Invalid input. Please input a valid response"<<endl;
  421. cin>>option;
  422. }
  423. }
  424. }
  425. }
  426. else if(pick=='p')
  427. { cout<<"You picked 'Paper'"<<endl;
  428. compChoice= rand()%3+1;
  429. if(compChoice==1)//1 is represented as rock
  430. { cout<<"The computer choose 'rock' "<<endl<<"This round goes to you "<<endl<<endl;
  431. playerCount++;
  432. if(playerCount==3)
  433. { cout<<"You won this round and the game!"<<endl<<endl;
  434. cout<<"1) Play this game"<<endl<<"2) Go to the main menu"<<endl<<"3) Exit program"<<endl;
  435. cin>>option;
  436. if(option==3)
  437. exit(1);
  438. else if(option==2)
  439. Choices();
  440. else if(option==1)
  441. Rock_Paper_Scissors();
  442. else while((option<1)||(option>3))
  443. { cout<<"Invalid input. Please input a valid response"<<endl;
  444. cin>>option;
  445. }
  446. }
  447.  
  448. }
  449. else if(compChoice==2)//2 represents paper.
  450. { cout<<"The computer choose 'Paper' "<<endl<<"This round is a tie. Nobody wins"<<endl;
  451. }
  452. else if(compChoice==3)//3 represents scissors.
  453. { compCount++;
  454. cout<<"The computer choose 'Scissors'"<<endl;
  455. cout<<"The computer wins this round"<<endl<<endl;
  456. if(compCount==3)
  457. { cout<<"The computer wins this round and the game!"<<endl<<endl;
  458. cout<<"1) Play this game"<<endl<<"2) Go to the main menu"<<endl<<"3) Exit program"<<endl;
  459. cin>>option;
  460. if(option==3)
  461. exit(1);
  462. else if(option==2)
  463. Choices();
  464. else if(option==1)
  465. Rock_Paper_Scissors();
  466. else while((option<1)||(option>3))
  467. { cout<<"Invalid input. Please input a valid response"<<endl;
  468. cin>>option;
  469. }
  470. }
  471. }
  472. }
  473. else if(pick == 's')
  474. { cout<<"You picked 'Scissors'"<<endl;
  475. compChoice=rand()%3+1;
  476. if(compChoice==1)//1 represents rock
  477. { compCount++;
  478. cout<<"The computer choose 'Rock'"<<endl;
  479. cout<<"The computer wins this round"<<endl<<endl;
  480. if(compCount==3)
  481. { cout<<"The computer won this round and the game!"<<endl<<endl;
  482. cout<<"1) Play this game"<<endl<<"2) Go to the main menu"<<endl<<"3) Exit program"<<endl;
  483. cin>>option;
  484. if(option==3)
  485. exit(1);
  486. else if(option==2)
  487. Choices();
  488. else if(option==1)
  489. Rock_Paper_Scissors();
  490. else while((option<1)||(option>3))
  491. { cout<<"Invalid input. Please input a valid response"<<endl;
  492. cin>>option;
  493. }
  494. }
  495. }
  496. else if(compChoice==2)//2 represents paper
  497. { playerCount++;
  498. cout<<"The computer choose 'paper'"<<endl;
  499. cout<<"You win this round"<<endl<<endl;
  500. if(playerCount==3)
  501. { cout<<"You won this round and the game!"<<endl<<endl;
  502. cout<<"1) Play this game"<<endl<<"2) Go to the main menu"<<endl<<"3) Exit program"<<endl;
  503. cin>>option;
  504. cout<<endl;
  505. if(option==3)
  506. exit(1);
  507. else if(option==2)
  508. { Choices();
  509. break;
  510.  
  511. }
  512. else if(option==1)
  513. Rock_Paper_Scissors();
  514. else while((option<1)||(option>3))
  515. { cout<<"Invalid input. Please input a valid response"<<endl;
  516. cin>>option;
  517.  
  518. }
  519. }
  520. }
  521.  
  522.  
  523. else if(compChoice==3)//3 represents scissors
  524. { cout<<"The computer choose 'scissor'"<<endl<<"This round is a tie"<<endl;
  525. }
  526.  
  527.  
  528.  
  529. }
  530.  
  531.  
  532. }
  533. }while(compCount!=3||playerCount!=3|| option==2);
  534. }
Last edited by firstPerson; Dec 8th, 2008 at 6:01 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 392
Reputation: StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light StuXYZ is a glorious beacon of light 
Solved Threads: 72
StuXYZ StuXYZ is offline Offline
Posting Whiz

Re: Can I recive some feedback with my c++ program?

 
0
  #2
Dec 8th, 2008
First off, if you want some constructive feedback my immediate question is why, (a) you are learning C++/programming for fun and decided to write some code and want to have some feed back.
(b) you are taking a class and this is to be marked, and you are hoping to improve it. (c) other...

Actually both (a) and (b) and maybe (c) are good. But it causes a difference in what I say about the code.

First off:

Is there anything that is c++ in it other than the std::cout/cin ?
There are no classes / use of the stl, etc.
If you are starting with C and moving up not a problem, for a c++ class, not so good.

Layout.... Arrh!!!!! -- That is not good.

Beyond that shuffle stands out as awful. It will not result in particularly random cards.

There are a number of exit(1) lines. This is a bit ungraceful.

The conditional breaks are very very difficult to follow. I think that is were you need to code round your logic. [I mean the
if (condition) break; that litter the code.]


For this kind of task, my next step would be to write a simple command parser, so that games could be played simultaniously.
(I don't mean across computers, but command could be simple letters to start a game eg.

  1. play B // play blackjack
  2. B b 50 // bet 50
  3. B show // show cards (again)
  4. B card // get an exxtra card
  5. B hold // hold
  6. play RPS // play rock paper scissors
  7. R 1 // select rock etc.
  8. B show // back to blackjack again

you really don't have to take my advice on that, but I was trying to see a way to get you out of the loop in a loop in a loop structure you have, but at the same time not require you to write a full GUI.

Also after a while (say 1 turn) the user is bored with the messages telling him what to do. I would only do that if the user typed help.

Enjoy the coding.
experience is the most expensive way to learn anything
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,151
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 145
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: Can I recive some feedback with my c++ program?

 
0
  #3
Dec 8th, 2008
Originally Posted by StuXYZ View Post
First off, if you want some constructive feedback my immediate question is why, (a) you are learning C++/programming for fun and decided to write some code and want to have some feed back.
(b) you are taking a class and this is to be marked, and you are hoping to improve it. (c) other...

Actually both (a) and (b) and maybe (c) are good. But it causes a difference in what I say about the code.

First off:

Is there anything that is c++ in it other than the std::cout/cin ?
There are no classes / use of the stl, etc.
If you are starting with C and moving up not a problem, for a c++ class, not so good.

Layout.... Arrh!!!!! -- That is not good.

Beyond that shuffle stands out as awful. It will not result in particularly random cards.

There are a number of exit(1) lines. This is a bit ungraceful.

The conditional breaks are very very difficult to follow. I think that is were you need to code round your logic. [I mean the
if (condition) break; that litter the code.]


For this kind of task, my next step would be to write a simple command parser, so that games could be played simultaniously.
(I don't mean across computers, but command could be simple letters to start a game eg.

  1. play B // play blackjack
  2. B b 50 // bet 50
  3. B show // show cards (again)
  4. B card // get an exxtra card
  5. B hold // hold
  6. play RPS // play rock paper scissors
  7. R 1 // select rock etc.
  8. B show // back to blackjack again

you really don't have to take my advice on that, but I was trying to see a way to get you out of the loop in a loop in a loop structure you have, but at the same time not require you to write a full GUI.

Also after a while (say 1 turn) the user is bored with the messages telling him what to do. I would only do that if the user typed help.

Enjoy the coding.
Thanks StuXYZ for the constructive criticism.

I have not taken any programming class except this c++ ( if that answers one of your question)

Your advice helps, because a program should be efficient as possible.

And your idea of the game sampler sounds like a cool idea. I will try to implement that algorithm. And again thanks for your comment.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,151
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 145
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: Can I recive some feedback with my c++ program?

 
0
  #4
Dec 8th, 2008
One more thing. this program supposed to be user friendly. what do you think?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,151
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 145
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: Can I recive some feedback with my c++ program?

 
0
  #5
Dec 8th, 2008
No more opinions?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: mahlerfive is an unknown quantity at this point 
Solved Threads: 16
mahlerfive mahlerfive is offline Offline
Junior Poster in Training

Re: Can I recive some feedback with my c++ program?

 
0
  #6
Dec 8th, 2008
Have you learned about classes in your course yet? If so then you should be using them. If not, you should at least break your functions up into smaller, more manageable functions. Also you should learn how and when to use header files and multiple cpp files rather than having everything in one big file.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,151
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 145
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Veteran Poster

Re: Can I recive some feedback with my c++ program?

 
0
  #7
Dec 8th, 2008
More oppions the marrier
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