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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int getRand();
void Rolldie( int num0,int num1, int num2, int num3, int num4, int num5,int num6,int num7);
void results (int num0,int num1, int num2, int num3, int num4, int num5,int num6, int num7);
void score( int num0,int num1, int num2, int num3, int num4, int num5,int num6, int num7);
int main()
{
int num0=0,num1=0, num2=0, num3=0, num4=0, num5=0, num6=0,num7=0;
srand(time(NULL));
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;
system ("Pause");
cout<<endl;
cout << player1 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout<<endl;
cout << player2 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout << player1 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout<<endl;
cout << player2 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout << player1 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout<<endl;
cout << player2 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout << player1 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout<<endl;
cout << player2 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout << player1 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout<<endl;
cout << player2 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout << player1 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout<<endl;
cout << player2 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout << player1 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
cout<<endl;
cout << player2 << " rolled:";
Rolldie(num0,num1,num2,num3,num4,num5,num6,num7);
system("PAUSE");
}
void Rolldie (int num0,int num1, int num2, int num3, int num4, int num5,int num6,int num7)
{
int num;
int counter = 0;
while (counter <= 5)// loop which allows code to be executed repeatedly
{
num = rand() % 6+1;//gives the random generated number (num)between 1 to 6
cout << " " << num << " " ;
if (num==0)// if else statements that determines the numbers generated
num0++;
else if(num == 1)
num1++;
else if(num == 2)
num2++;
else if(num == 3)
num3++;
else if(num == 4)
num4++;
else if(num == 5)
num5++;
else if(num == 6)
num6++;
else
num7++;
counter++;
}
int results (int num0,int num1, int num2, int num3, int num4, int num5,int num6, int num7);
//results will return the amount of 1's to 6's that are randomly generated
{
cout << num << endl;
}
int score (int num0,int num1, int num2, int num3, int num4, int num5,int num6, int num7);
{
int total0=num0*0;
int total1=num1*1*100;
int total2=num2*2*100;
int total3=num3*3*100;
int total4=num4*4*100;
int total5=num5*5*100;
int total6=num6*6*100;
int T_total= total0 + total1 + total2 + total3 + total4 + total5 + total6;
cout<<endl;
cout<<" Roll points is: "<<" "<< T_total <<endl;//returns the overall score
}
}
|