1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include <cstdlib>
#include <iostream>
using namespace std;
int getRand();
void roll7 (int num1,int num2, int num3, int num4, int num5,int num6,int num7) ;//function prototype for number of dice rolls
void score( int num1, int num2, int num3, int num4, int num5,int num6, int num7); //function for numbers rolled
//void playturn ( int roll ,string player1,string player2);
void info(string player1,string player2) ;//start-up information
int main()
{
int num1, num2, num3, num4, num5, num6,num7;
srand(time(NULL));
// sum = 0;
num1 = getRand();
num2 = getRand();
num3 = getRand();
num4 = getRand();
num5 = getRand();
num6 = getRand();
num7 = getRand();
roll7(num1, num2, num3, num4, num5, num6, num7);
score(num1, num2, num3, num4, num5, num6, num7);
system("PAUSE");
return EXIT_SUCCESS;
}
void info()
{
string player1;
string player2;
cout << "Welcome to the Dice Roller! The simple rule of this game is to roll"<< endl;
cout << "the die and finish on a total score of 10,000 or more points."<< endl << endl;
cout << "Player 1, please enter your name: ";
cin >> player1;
cout<< endl;
cout << "Welcome, " << player1 << "."<< endl << endl;
cout << "Player 2, please enter your name: ";
cin >> player2;
cout<< endl;
cout << "Welcome, " << player2 << "."<< endl << endl;
cout << "Let's begin!" << endl << endl;
system("PAUSE");
}
int getRand()
{
return (rand()%6 +1);
}
void rolldie (int num1, int num2, int num3, int num4, int num5,int num6,int num7)
{
if (num1 < 0)
num1++;
if (num2 < 0)
num2++;
if (num3 < 0)
num3++;
if (num4 < 0)
num4++;
if (num5 < 0)
num5++;
}
void score( int num1, int num2, int num3, int num4, int num5,int num6, int num7)
{
string player1,player2;
cout << " Player :" << player1 << " "<< num1 <<" "<< num2 <<" "<< num3 <<" "<< num4 <<" "<< num5 <<" "<< num6 <<" "<< num7 << endl;
cout << " Player :" << player2 << " "<< num1 <<" "<< num2 <<" "<< num3 <<" "<< num4 <<" "<< num5 <<" "<< num6 <<" "<< num7 << endl;
cout <<"1 was repeted " << num1 << " times "<<" the score is :"<<endl;
cout << "2 was repeted " << num2 << " times "<<" the score is :"<<endl;
cout << "3 was repeted " << num3 << " times "<<" the score is :"<<endl;
cout << "4 was repeted " << num4 << " times "<<" the score is :"<<endl;
cout << "5 was repeted " << num5 << " times "<<" the score is :"<<endl;
cout << "6 was repeted " << num6 << " times "<<" the score is :"<<endl;
}
}
|