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.

/*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;
}
2
Contributors
1
Reply
2
Views
13 Years
Discussion Span
Last Post by infamous
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.