Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- class player
- {
- public:
- string name;
- int Accuracy;
- int Bulls_Hit;
- int DartsThrown;
- //functions
- void PrintAll()
- {
- cout << name << endl;
- cout << Accuracy << endl;
- cout << Bulls_Hit << endl;
- cout << DartsThrown << endl;
- }
- int DoesitHit() //Random Number to generte if they hit
- {
- int Throw = rand() % 100 + 1;
- cout << Throw << endl;
- return Throw;
- }
- bool Game() //hit check
- {
- if (Bulls_Hit < 10)
- {
- int Throw = DoesitHit();
- //cout << Throw << endl;
- if (Throw > Accuracy)
- {
- cout << name << " Missed :(" << endl;
- DartsThrown++;
- return false;
- }
- else if (Throw <= Accuracy)
- {
- cout << name << " Hit :)" << endl;
- Bulls_Hit++;
- DartsThrown++;
- return true;
- }
- }
- }
- int play()
- {
- cout << "Joe Throws First" << endl;
- for (int x = 0; x < 3; x++)
- {
- Game();
- WinningCondition();
- }
- cout << "Sid Throws Next" << endl;
- for (int x = 0; x < 3; x++)
- {
- Game();
- WinningCondition();
- }
- PrintAll();
- PrintAll();
- }
- int GetBulls()
- {
- return Bulls_Hit;
- }
- void GetName()
- {
- return name;
- }
- void WinningCondition()
- {
- if (Bulls_Hit == 10)
- {
- cout << name << "Hit the Bulls Eye 10 times, They Won! :D" << endl;
- }
- else if (Bulls_Hit != 10)
- {
- return;
- }
- }
- };
- int main()
- {
- srand(time(0));
- player Joe;
- Joe.name = "Joe";
- Joe.Accuracy = 71;
- Joe.Bulls_Hit = 0;
- Joe.DartsThrown = 0;
- int JoeBulls = 0;
- int SidBulls = 0;
- string PlayerName;
- player Sid;
- Sid.name = "Sid";
- Sid.Accuracy = 73;
- Sid.Bulls_Hit = 0;
- Sid.DartsThrown = 0;
- Joe.PrintAll();
- Sid.PrintAll();
- //Joe.DoesitHit();
- //Joe.Game();
- JoeBulls = Joe.GetBulls();
- SidBulls = Sid.GetBulls();
- PlayerName = Joe.Getname();
- PlayerName = Sid.Getname();
- if (JoeBulls > 10 || SidBulls > 10)
- {
- cout << name << "Hit the Bull 10 times, They Win!" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement