rendered paste body#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int repeat;
int check = 0;
int sum;
class game {
private:
int ppoint;
public:
void fround();
void calc();
void get_die(int& die1, int& die2, int& sum) {
die1 = rand() % 6 + 1;
die2 = rand() % 6 + 1;
sum = die1 + die2;
}
void show_die(int die1, int die2, int sum) {
do {
if(check == 0) {
cout << "First die: " << die1 << "\nSecond die: " << die2 << "\nSum of the dice: " << sum << endl;
fround();
}
else if(check = 1) {
calc();
}
}
while(repeat = 0);
}
};
void game::fround() {
if( sum == 7 || sum == 11 ) {
cout << "You win!!";
repeat = 1;
}
else if( sum == 2 || sum == 3 || sum == 12 ) {
cout << "You lose!!!";
repeat = 1;
}
else {
repeat = 0;
ppoint = sum;
check = 1;
}
}
void game::calc() {
if( sum == ppoint ) {
cout << "You win!!";
repeat = 1;
}
else if( sum == 7 ) {
cout << "You lose!!!";
repeat = 1;
}
}
int main() {
srand( time(NULL) );
game craps;
int die1;
int die2;
do {
craps.get_die(die1, die2, sum);
craps.show_die(die1, die2, sum);
}
while( repeat = 0 );
system("pause");
return 0;
}