| | |
C craps game
![]() |
•
•
Join Date: May 2004
Posts: 1
Reputation:
Solved Threads: 0
hi people i was wondering how you create a test plan im new to this and just created my 1st c game... need some help as im not sure how to create a test plan preferably in a table.
C Syntax (Toggle Plain Text)
/*In order to play the game of craps. each player rolls 2 dice. Each die has 6 faces. These faces contain 1, 2, 3, 4, 5, and 6 spots. After the dice have come to rest, the sum of the spots on the 2 upward faces is calculated. If the sum is 7 or 11 on the first throw, the player wins. If the sum is 2, 3, or 12 on the first throw (called "craps"), the payer loses (i.e., the "house" wins). If the sum is 4, 5, 6, 8, 9, or 10 on the first throw, then that sum becomes the player's "point". To win, the player must continue rolling the dice until he/she "makes the point". You lose by rolling a 7 before making the point.*/ #include <stdio.h> ////fuction prototypes for standard I/O library fuctions #include <stdlib.h> //function prototypes for conversion of numbers to text and text to numbers, random numbers #include <time.h> //fuction prototypes and types for manimpulating time and date int rollDice(void); main() { printf(" **** **** * **** *** \n"); printf(" * * * * * * * * \n"); printf(" * *--* *---* *--* * \n"); printf(" * * * * * * * \n"); printf(" **** * * * * * *** \n"); printf(" G A M E \n\n"); printf(" --- --- --- \n"); printf(" |O O| |O O| |O O| \n"); printf(" |O O| | O | | | \n"); printf(" |O O| |O O| |O O| \n"); printf(" ---\t ---\t --- \n"); printf(" Created by Timothy \n\n\n"); printf("-------------------------------------------------\n\n"); int CONTINUE; int gameStatus; int sum; int myPoint; char roll; char r; do{ printf("To roll dice press (r) :\n\n"); scanf("%c",&r); while(roll==r); srand((unsigned)time(NULL)); sum=rollDice(); switch(sum){ case 7: case 11: gameStatus=1;//won break; case 2: case 3: case 12: gameStatus =2;//lost break; default: gameStatus =0; myPoint =sum; printf("\t your current point is %d\n",myPoint); break; } while(gameStatus==0) { sum=rollDice(); if(sum==myPoint) { gameStatus =1; } else { if(sum==7) gameStatus=2; } } if(gameStatus==1) { printf("\t YOU WIN $$$$$$$$$$ lucky roll!\n\n\t\t******\n\a"); } else { printf("\t YOU LOSE! try again !\n\n\a"); } printf("\t Do you wish to continue?\n\n\t Press (-1) to continue (-2) to end) :\n"); //control flag gives the user an option to try the game of craps again scanf("%d", &CONTINUE); }while(CONTINUE==-1); if(CONTINUE==-2){ ; } return 0; } int rollDice() { int dice1,dice2,worksum; dice1 = 1 + (rand()%6); dice2 = 1 + (rand()%6); worksum = dice1 + dice2; printf("\t player rolled %d + %d = %d\n",dice1,dice2,worksum); return worksum; return 0; }
•
•
Join Date: Mar 2004
Posts: 77
Reputation:
Solved Threads: 2
a test plan is designed to test the robustness of your program. if you are taking in any input from the user, you would want to try many values for those inputs. most importantly, u would want to try values that a "nice" user wouldn't give u. for example, would ur program properly handle a negative value? would it properly handle the user entering NO value at all, and just sendin u EOF?
![]() |
Similar Threads
- Simple Craps Game (C++)
- Python Craps Game (Python)
- Assistance needed with craps game (C++)
- Need some Help with PHP Craps game! (PHP)
- Craps, game help! (C++)
Other Threads in the C Forum
- Previous Thread: Possibility of mini servers
- Next Thread: sorting file
| Thread Tools | Search this Thread |
* adobe ansi api array asterisks binarysearch calculate centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory feet fflush fgets file fork forloop frequency givemetehcodez grade graphics gtkgcurlcompiling gtkwinlinux hacking highest histogram homework i/o inches infiniteloop input intmain() iso kernel keyboard km linked linkedlist linux linuxsegmentationfault list locate looping loopinsideloop. lowest match microsoft mqqueue mysql number oddnumber odf open opendocumentformat owf pattern pdf performance posix probleminc process program programming radix recv recvblocked repetition research reversing scanf scheduling segmentationfault send sequential socket socketprograming stack standard string systemcall threads turboc unix user variable voidmain() wab whythiscodecausesegmentationfault windows.h windowsapi





