i was asked to make a craps game using empty console in c++
roll two dice. Each die has six faces representing values 1,2...., and 6, respectively. Check the sum of the two dice. If the sum is 2,3, or 12 (called craps), you lose; if the sum is 7 or 11 (called natural), you win; if the sum is another value (ie., 4,5,6,7,8,9,10), a point is established. Continue until you roll either a 7 (you lose) or the same point value (you win).
Your program acts as a single player.
i need to add 3 void functions:
void GetRoll(int &);
void CalcSum(int, int, int &);
void PrintRoll(int, int, int);
this is wat i have so far:
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
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void GetRoll(int &);
void CalcSum(int, int, int &);
void PrintRoll(int, int, int);
int main()
{
const int dice = 6;
srand((unsigned)time(0)); //sets a new seed for random function
int RollDie,rolldice2, TotalRoll;
GetRoll(RollDie);
CalcSum(RollDie, rolldice2, TotalRoll);
PrintRoll(one, two, three);
return 0;
}
int GetRoll(int & RollDie)
{
RollDie = rand()%7;
}
void CalcSum(int RollDie,int rolldice2, int & TotalRoll)
{
TotalRoll = RollDie + RollDie2;
}
void PrintRoll(int, int, int);
{
cout << "You rolled: " << RollDie << " + " << RollDie2 << " = " << TotalRoll << endl;
}
|
what i need help with, is how to get two random values, using one parameter in the void GetRoll, then somehow having it in two parameters for the Void CalcSum and Void PrintRoll.
any help will be appreciated....
asap ty.