You are on page 1of 3

#include <iostream>

#include <ctime>
using namespace std;
double Player_1();
double Player_2();
int score(double secret1, double secret2);
int main ()
{
double secret1, secret2;
cout << "Lets Play PIGS!!" << endl;
cout << endl;
Player_1();
Player_2();
score(secret1, secret2);
}
double Player_1()
{
cout << endl;
srand((unsigned)time(NULL));
int secret1, secret2;
char again;
cout << "Player 1, it's your turn!" << endl;
cout << endl;
do
{
secret1 = rand() % 6 + 1;
secret2 = rand() % 6 + 1;
cout << "You rolled a " << secret1 << " and a "<<
secret2 << endl;
if(secret1 == 1 && secret2 == 2)
{
}
if(secret1 == 1 || secret2 == 1)
{
cout << "You rolled a one, your turn is
over."<<endl;
Player_2();
}

cout << "Your score after this turn is " <<


score(secret1,secret2) << endl;
cout << "Would you like to roll again?";
cin >> again;
if(again == 'n' || again == 'N')
{
Player_2();
}
}while(again == 'Y' || again == 'y');
return 0;
cout << endl;
}
double Player_2()
{
cout << endl;
srand((unsigned)time(NULL));
int secret1, secret2;
char again;
cout << "Player 2, it's your turn!" << endl;
cout << endl;
do
{
secret1 = rand() % 6 + 1;
secret2 = rand() % 6 + 1;
cout << "You rolled a " << secret1 << " and a "<<
secret2 << endl;
if(secret1 == 1 || secret2 == 1)
{
cout << "You rolled a one, your turn is
over."<<endl;
Player_1();
}
cout << "Your score after this turn is " <<
score(secret1,secret2) << endl;
cout << "Would you like to roll again?";
cin >> again;
if(again == 'n' || again == 'N')

{
Player_1();
}
}while(again == 'Y' || again == 'y');
return 0;
}
int score(double secret1, double secret2)
{
double score1;
score1 = secret1 + secret2;
return score1;
}

You might also like