From 18732517070bf5cc447ea0689329fd3ceee115aa Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 11:08:50 -0700 Subject: [PATCH 01/15] Created Initial Classes --- AI.cpp | 0 AI.h | 13 +++++++++++++ Dice.cpp | 0 Dice.h | 12 ++++++++++++ Main.cpp | 11 +++++++++++ Player.cpp | 26 ++++++++++++++++++++++++++ Player.h | 24 ++++++++++++++++++++++++ 7 files changed, 86 insertions(+) create mode 100644 AI.cpp create mode 100644 AI.h create mode 100644 Dice.cpp create mode 100644 Dice.h create mode 100644 Main.cpp create mode 100644 Player.cpp create mode 100644 Player.h diff --git a/AI.cpp b/AI.cpp new file mode 100644 index 0000000..e69de29 diff --git a/AI.h b/AI.h new file mode 100644 index 0000000..01991de --- /dev/null +++ b/AI.h @@ -0,0 +1,13 @@ +#ifndef __AI__ +#define __AI__ + +#include "Player.h" + +class AI : Player +{ +private: +public: + int RollDie(); +}; + +#endif \ No newline at end of file diff --git a/Dice.cpp b/Dice.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Dice.h b/Dice.h new file mode 100644 index 0000000..fe4a6e9 --- /dev/null +++ b/Dice.h @@ -0,0 +1,12 @@ +#ifndef __DICE__ +#define __DICE__ + +class Dice +{ +private: + const int Sides = 6; +public: + int RollDice(); +}; + +#endif \ No newline at end of file diff --git a/Main.cpp b/Main.cpp new file mode 100644 index 0000000..4bd724c --- /dev/null +++ b/Main.cpp @@ -0,0 +1,11 @@ +#include "Player.h" +#include "AI.h" + +#include + +int main() +{ + + + return 0; +} \ No newline at end of file diff --git a/Player.cpp b/Player.cpp new file mode 100644 index 0000000..a72f0fe --- /dev/null +++ b/Player.cpp @@ -0,0 +1,26 @@ +#include "Player.h" + +int Player::RollDie(Dice *Die) +{ + int tmp = Die->RollDice(); + + if (tmp == 1) + { + TempScore = 0; + Hold = true; + } + else + { + TempScore += tmp; + } +} + +bool Player::Get_Hold() +{ + return Hold; +} + +void Player::Set_Hold(bool toHold) +{ + Hold = toHold; +} \ No newline at end of file diff --git a/Player.h b/Player.h new file mode 100644 index 0000000..4a06d5d --- /dev/null +++ b/Player.h @@ -0,0 +1,24 @@ +#ifndef __PLAYER__ +#define __PLAYER__ + +#include "Dice.h" + +class Player +{ +private: + int TempScore; + int OverallScore; + bool Hold; + +public: + + + Player() : TempScore(0), OverallScore(0), Hold(false) + {} + + virtual int RollDie(Dice *Die); //Roll of non 1 adds to TempScore, roll of 1: TempScore = 0 + bool Get_Hold(); + void Set_Hold(bool); +}; + +#endif \ No newline at end of file From 91ae77473d65fb79ba7cfa0b6c272aa146b223aa Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 11:43:09 -0700 Subject: [PATCH 02/15] Added functions for access to TempScore and OverallScore --- Player.cpp | 11 +++++++++++ Player.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/Player.cpp b/Player.cpp index a72f0fe..9784a6d 100644 --- a/Player.cpp +++ b/Player.cpp @@ -13,6 +13,7 @@ int Player::RollDie(Dice *Die) { TempScore += tmp; } + return tmp; } bool Player::Get_Hold() @@ -23,4 +24,14 @@ bool Player::Get_Hold() void Player::Set_Hold(bool toHold) { Hold = toHold; +} + +int Player::Get_Score() +{ + return OverallScore; +} + +int Player::Get_TempScore() +{ + return TempScore; } \ No newline at end of file diff --git a/Player.h b/Player.h index 4a06d5d..3c0d3d6 100644 --- a/Player.h +++ b/Player.h @@ -19,6 +19,8 @@ class Player virtual int RollDie(Dice *Die); //Roll of non 1 adds to TempScore, roll of 1: TempScore = 0 bool Get_Hold(); void Set_Hold(bool); + int Get_Score(); + int Get_TempScore(); }; #endif \ No newline at end of file From 9991012b4221ed263b615f0030ad0722863cdbd3 Mon Sep 17 00:00:00 2001 From: CAGD Student Date: Mon, 14 Sep 2015 15:04:01 -0700 Subject: [PATCH 03/15] //Scott Backer 9/14/15 3:03 PM -- Added the Roll Dice and End Turn functions to the AI class --- AI.cpp | 32 ++++++++++++++++++++++++++++++++ AI.h | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/AI.cpp b/AI.cpp index e69de29..fb54721 100644 --- a/AI.cpp +++ b/AI.cpp @@ -0,0 +1,32 @@ +#include "AI.h" + +int AI::RollDie(Dice *Die) +{ + int RolledNumber = Die.RollDie(); + + if(RolledNumber == 1) + { + TempScore = 0; + Hold = true; + } + + else + { + if(TempScore < 12) + { + TempScore += RolledNumber; + } + + else + { + Hold = true; + } + } +} + +void AI::EndTurn() +{ + OverallScore += TempScore; + TempScore = 0; + Hold = false; +} \ No newline at end of file diff --git a/AI.h b/AI.h index 01991de..ee6bcf7 100644 --- a/AI.h +++ b/AI.h @@ -7,7 +7,8 @@ class AI : Player { private: public: - int RollDie(); + override int RollDie(Dice *Die); + void EndTurn(); }; #endif \ No newline at end of file From 5adde016987af12515a14dbc76167660d85698fe Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 16:19:34 -0700 Subject: [PATCH 04/15] Started Implementing the Main game logic. Main game logic for a human player now fully implemented. --- Main.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Main.cpp diff --git a/Main.cpp b/Main.cpp new file mode 100644 index 0000000..ce9a9dc --- /dev/null +++ b/Main.cpp @@ -0,0 +1,55 @@ +#include "Player.h" +#include "AI.h" + +#include +#include + +using namespace std; + +int main() +{ + srand(time(NULL)); + + Player Player1; + AI Computer1; + Dice Die; + + while (!(Player1.Get_Score() >= 100) || !(Computer1.Get_Score() >= 100)) + { + int input; + + while (!Player1.Get_Hold()) + { + std::cout << "Roll Dice(1) or Hold(2)?" << endl; + cin >> input; + + if (input == 1) + { + int tmp = Player1.RollDie(&Die); + + std::cout << "Dice Rolled a: " << tmp << endl; + std::cout << "Running Score is: " << Player1.Get_TempScore(); + cout << "Current Overall Score is: " << Player1.Get_Score() << endl; + } + else if (input == 2) + { + Player1.Set_Hold(true); + + std::cout << "New Overall Score: " << Player1.Get_Score() << endl; + } + } + /* + while (!Computer1.Get_Hold()) + { + Computer1.RollDie(&Die); + + cout << "Computers Running Score: " << Computer1.Get_TempScore(); + } + */ + + + Computer1.Set_Hold(false); + } + + return 0; +} \ No newline at end of file From ff74fa39f5896cac0a29f901a2bc283bd1fdd396 Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 16:21:00 -0700 Subject: [PATCH 05/15] Player Class Implementation Player Class now fully implemented. --- Player.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ Player.h | 26 ++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 Player.cpp create mode 100644 Player.h diff --git a/Player.cpp b/Player.cpp new file mode 100644 index 0000000..dcd0b20 --- /dev/null +++ b/Player.cpp @@ -0,0 +1,42 @@ +#include "Player.h" + +int Player::RollDie(Dice *Die) +{ + int RolledNumber = Die->RollDice(); + + if (RolledNumber == 1) + { + TempScore = 0; + Hold = true; + } + else + { + TempScore += RolledNumber; + } + return RolledNumber; +} + +bool Player::Get_Hold() +{ + return Hold; +} + +void Player::Set_Hold(bool toHold) +{ + if (toHold) + { + OverallScore += TempScore; + TempScore = 0; + Hold = toHold; + } +} + +int Player::Get_Score() +{ + return OverallScore; +} + +int Player::Get_TempScore() +{ + return TempScore; +} \ No newline at end of file diff --git a/Player.h b/Player.h new file mode 100644 index 0000000..3c0d3d6 --- /dev/null +++ b/Player.h @@ -0,0 +1,26 @@ +#ifndef __PLAYER__ +#define __PLAYER__ + +#include "Dice.h" + +class Player +{ +private: + int TempScore; + int OverallScore; + bool Hold; + +public: + + + Player() : TempScore(0), OverallScore(0), Hold(false) + {} + + virtual int RollDie(Dice *Die); //Roll of non 1 adds to TempScore, roll of 1: TempScore = 0 + bool Get_Hold(); + void Set_Hold(bool); + int Get_Score(); + int Get_TempScore(); +}; + +#endif \ No newline at end of file From b775683ea6be24368558bf3f244523e307060a7f Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 17:13:14 -0700 Subject: [PATCH 06/15] Implemented AI logic Finished implementing the Ai logic and with that finished implementing the main game logic --- Main.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Main.cpp b/Main.cpp index ce9a9dc..f883f1f 100644 --- a/Main.cpp +++ b/Main.cpp @@ -9,15 +9,15 @@ using namespace std; int main() { srand(time(NULL)); - + Player Player1; AI Computer1; Dice Die; - while (!(Player1.Get_Score() >= 100) || !(Computer1.Get_Score() >= 100)) + while (!(Player1.Get_Score() >= 100) && !(Computer1.Get_Score() >= 100)) { - int input; - + int input = 0; + while (!Player1.Get_Hold()) { std::cout << "Roll Dice(1) or Hold(2)?" << endl; @@ -28,7 +28,7 @@ int main() int tmp = Player1.RollDie(&Die); std::cout << "Dice Rolled a: " << tmp << endl; - std::cout << "Running Score is: " << Player1.Get_TempScore(); + std::cout << "Running Score is: " << Player1.Get_TempScore() << endl; cout << "Current Overall Score is: " << Player1.Get_Score() << endl; } else if (input == 2) @@ -38,18 +38,32 @@ int main() std::cout << "New Overall Score: " << Player1.Get_Score() << endl; } } - /* + + cout << endl; + while (!Computer1.Get_Hold()) { - Computer1.RollDie(&Die); - - cout << "Computers Running Score: " << Computer1.Get_TempScore(); + cout << "Computers Rolls: " << Computer1.RollDie(&Die) << endl; } - */ + cout << "Computers New Overall Score: " << Computer1.Get_Score() << endl; + + cout << endl; + Player1.Set_Hold(false); Computer1.Set_Hold(false); } + if (Player1.Get_Score() >= 100) + { + cout << "Player One is the winner!!!"; + } + else + { + cout << "The Computer is the winner!!!"; + } + cin.ignore(); + cin.get(); + return 0; } \ No newline at end of file From beec5a22f4587ddcb5695611bf2791347d11d4a0 Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 17:14:44 -0700 Subject: [PATCH 07/15] Few more changes to the player class to give access to protected members exposed some private vars to be protected so they can be used in classes that derive from it --- Player.cpp | 4 ++++ Player.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Player.cpp b/Player.cpp index dcd0b20..c281471 100644 --- a/Player.cpp +++ b/Player.cpp @@ -29,6 +29,10 @@ void Player::Set_Hold(bool toHold) TempScore = 0; Hold = toHold; } + else + { + Hold = false; + } } int Player::Get_Score() diff --git a/Player.h b/Player.h index 3c0d3d6..2f9c721 100644 --- a/Player.h +++ b/Player.h @@ -5,7 +5,7 @@ class Player { -private: +protected: int TempScore; int OverallScore; bool Hold; From 456ffc2e23a2fbb1353508ef3b2a6fc5a2cc6334 Mon Sep 17 00:00:00 2001 From: jBeller Date: Mon, 14 Sep 2015 18:19:29 -0700 Subject: [PATCH 08/15] Commit for Dice.cpp --- Dice.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dice.cpp b/Dice.cpp index e69de29..5926f11 100644 --- a/Dice.cpp +++ b/Dice.cpp @@ -0,0 +1,9 @@ +#include // For the random number generator +#include // Will use time as the random seed +#include "Dice.h" + +int Dice::RollDice() +{ + srand(time(NULL)); // Uses the current time as the random seed + return rand() % Sides + 1; // Return a random number between 1 and number of sides +} From d0b6c40ffdaaab4f1421984858addc9fc7cc0b59 Mon Sep 17 00:00:00 2001 From: Scott Backer Date: Mon, 14 Sep 2015 18:22:55 -0700 Subject: [PATCH 09/15] //Scott Backer 9/14/15 6:22 PM -- Updated functions with small adjustments to better suit overall game --- AI.cpp | 24 +++++++++--------------- AI.h | 5 ++--- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/AI.cpp b/AI.cpp index fb54721..609ec6d 100644 --- a/AI.cpp +++ b/AI.cpp @@ -2,31 +2,25 @@ int AI::RollDie(Dice *Die) { - int RolledNumber = Die.RollDie(); - - if(RolledNumber == 1) + int RolledNumber = Die->RollDice(); + + if (RolledNumber == 1) { TempScore = 0; Hold = true; } - else { - if(TempScore < 12) + TempScore += RolledNumber; + if (OverallScore + TempScore >= 100) { - TempScore += RolledNumber; + Set_Hold(true); } - - else + else if (TempScore > 12) { - Hold = true; + Set_Hold(true); } } -} -void AI::EndTurn() -{ - OverallScore += TempScore; - TempScore = 0; - Hold = false; + return RolledNumber; } \ No newline at end of file diff --git a/AI.h b/AI.h index ee6bcf7..38beafa 100644 --- a/AI.h +++ b/AI.h @@ -3,12 +3,11 @@ #include "Player.h" -class AI : Player +class AI : public Player { private: public: - override int RollDie(Dice *Die); - void EndTurn(); + int RollDie(Dice *Die); }; #endif \ No newline at end of file From 03590a1c2efdc0f3f6e28e6cc4afaa15cca83d86 Mon Sep 17 00:00:00 2001 From: jBeller Date: Mon, 14 Sep 2015 18:47:50 -0700 Subject: [PATCH 10/15] Updated Dice.h --- Dice.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Dice.h b/Dice.h index fe4a6e9..f43ca76 100644 --- a/Dice.h +++ b/Dice.h @@ -1,12 +1,16 @@ #ifndef __DICE__ #define __DICE__ +#include + class Dice { -private: - const int Sides = 6; -public: - int RollDice(); + private: + int Sides; + public: + int RollDice(){ Sides = 6; }; + + int Set_NumSides(int); }; -#endif \ No newline at end of file +#endif From 576aa52bebafe8876be75db0c909aac897d1e403 Mon Sep 17 00:00:00 2001 From: jBeller Date: Mon, 14 Sep 2015 18:49:44 -0700 Subject: [PATCH 11/15] Updated Dice.cpp --- Dice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dice.cpp b/Dice.cpp index 5926f11..82183ea 100644 --- a/Dice.cpp +++ b/Dice.cpp @@ -7,3 +7,7 @@ int Dice::RollDice() srand(time(NULL)); // Uses the current time as the random seed return rand() % Sides + 1; // Return a random number between 1 and number of sides } +int Dice::Set_NumSides(int Num) +{ + Sides = Num; +} From 94fc035cf4a37439b463f1b76ba553785abf71f7 Mon Sep 17 00:00:00 2001 From: jBeller Date: Mon, 14 Sep 2015 18:52:09 -0700 Subject: [PATCH 12/15] Updated Dice.h --- Dice.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dice.h b/Dice.h index f43ca76..1a3b545 100644 --- a/Dice.h +++ b/Dice.h @@ -8,8 +8,8 @@ class Dice private: int Sides; public: - int RollDice(){ Sides = 6; }; - + Dice(){ Sides = 6; } // Initialize with 6 sides + int RollDice(); int Set_NumSides(int); }; From 9f4d39a27249de4506f0cbafbd256ca7c7d01bda Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 19:04:32 -0700 Subject: [PATCH 13/15] fixed some formatting stuf --- Main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Main.cpp b/Main.cpp index f883f1f..6cd387b 100644 --- a/Main.cpp +++ b/Main.cpp @@ -20,22 +20,22 @@ int main() while (!Player1.Get_Hold()) { - std::cout << "Roll Dice(1) or Hold(2)?" << endl; + cout << "Roll Dice(1) or Hold(2)?" << endl; cin >> input; if (input == 1) { int tmp = Player1.RollDie(&Die); - std::cout << "Dice Rolled a: " << tmp << endl; - std::cout << "Running Score is: " << Player1.Get_TempScore() << endl; + cout << "Dice Rolled a: " << tmp << endl; + cout << "Running Score is: " << Player1.Get_TempScore() << endl; cout << "Current Overall Score is: " << Player1.Get_Score() << endl; } else if (input == 2) { Player1.Set_Hold(true); - std::cout << "New Overall Score: " << Player1.Get_Score() << endl; + cout << "New Overall Score: " << Player1.Get_Score() << endl; } } From ea311334def140baa33a2c52f5ec2080b317727e Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 19:08:06 -0700 Subject: [PATCH 14/15] Files Corrupted --- Main.cpp | 76 ------------------------------------------------------ Player.cpp | 62 -------------------------------------------- Player.h | 30 --------------------- 3 files changed, 168 deletions(-) delete mode 100644 Main.cpp delete mode 100644 Player.cpp delete mode 100644 Player.h diff --git a/Main.cpp b/Main.cpp deleted file mode 100644 index 13b52a7..0000000 --- a/Main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "Player.h" -#include "AI.h" - -#include -<<<<<<< HEAD - -int main() -{ - -======= -#include - -using namespace std; - -int main() -{ - srand(time(NULL)); - - Player Player1; - AI Computer1; - Dice Die; - - while (!(Player1.Get_Score() >= 100) && !(Computer1.Get_Score() >= 100)) - { - int input = 0; - - while (!Player1.Get_Hold()) - { - cout << "Roll Dice(1) or Hold(2)?" << endl; - cin >> input; - - if (input == 1) - { - int tmp = Player1.RollDie(&Die); - - cout << "Dice Rolled a: " << tmp << endl; - cout << "Running Score is: " << Player1.Get_TempScore() << endl; - cout << "Current Overall Score is: " << Player1.Get_Score() << endl; - } - else if (input == 2) - { - Player1.Set_Hold(true); - - cout << "New Overall Score: " << Player1.Get_Score() << endl; - } - } - - cout << endl; - - while (!Computer1.Get_Hold()) - { - cout << "Computers Rolls: " << Computer1.RollDie(&Die) << endl; - } - - cout << "Computers New Overall Score: " << Computer1.Get_Score() << endl; - - cout << endl; - - Player1.Set_Hold(false); - Computer1.Set_Hold(false); - } - - if (Player1.Get_Score() >= 100) - { - cout << "Player One is the winner!!!"; - } - else - { - cout << "The Computer is the winner!!!"; - } - cin.ignore(); - cin.get(); ->>>>>>> Ryan - - return 0; -} \ No newline at end of file diff --git a/Player.cpp b/Player.cpp deleted file mode 100644 index aae9488..0000000 --- a/Player.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "Player.h" - -int Player::RollDie(Dice *Die) -{ -<<<<<<< HEAD - int tmp = Die->RollDice(); - - if (tmp == 1) -======= - int RolledNumber = Die->RollDice(); - - if (RolledNumber == 1) ->>>>>>> Ryan - { - TempScore = 0; - Hold = true; - } - else - { -<<<<<<< HEAD - TempScore += tmp; - } - return tmp; -======= - TempScore += RolledNumber; - } - return RolledNumber; ->>>>>>> Ryan -} - -bool Player::Get_Hold() -{ - return Hold; -} - -void Player::Set_Hold(bool toHold) -{ -<<<<<<< HEAD - Hold = toHold; -======= - if (toHold) - { - OverallScore += TempScore; - TempScore = 0; - Hold = toHold; - } - else - { - Hold = false; - } ->>>>>>> Ryan -} - -int Player::Get_Score() -{ - return OverallScore; -} - -int Player::Get_TempScore() -{ - return TempScore; -} \ No newline at end of file diff --git a/Player.h b/Player.h deleted file mode 100644 index e37b1cc..0000000 --- a/Player.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __PLAYER__ -#define __PLAYER__ - -#include "Dice.h" - -class Player -{ -<<<<<<< HEAD -private: -======= -protected: ->>>>>>> Ryan - int TempScore; - int OverallScore; - bool Hold; - -public: - - - Player() : TempScore(0), OverallScore(0), Hold(false) - {} - - virtual int RollDie(Dice *Die); //Roll of non 1 adds to TempScore, roll of 1: TempScore = 0 - bool Get_Hold(); - void Set_Hold(bool); - int Get_Score(); - int Get_TempScore(); -}; - -#endif \ No newline at end of file From 9b13c939c15a01f602bc5b834ef3b214010817c4 Mon Sep 17 00:00:00 2001 From: Ryan Nolan Date: Mon, 14 Sep 2015 19:08:39 -0700 Subject: [PATCH 15/15] Restored Corrupted Files --- Main.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Player.cpp | 46 ++++++++++++++++++++++++++++++++++++ Player.h | 26 ++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 Main.cpp create mode 100644 Player.cpp create mode 100644 Player.h diff --git a/Main.cpp b/Main.cpp new file mode 100644 index 0000000..6cd387b --- /dev/null +++ b/Main.cpp @@ -0,0 +1,69 @@ +#include "Player.h" +#include "AI.h" + +#include +#include + +using namespace std; + +int main() +{ + srand(time(NULL)); + + Player Player1; + AI Computer1; + Dice Die; + + while (!(Player1.Get_Score() >= 100) && !(Computer1.Get_Score() >= 100)) + { + int input = 0; + + while (!Player1.Get_Hold()) + { + cout << "Roll Dice(1) or Hold(2)?" << endl; + cin >> input; + + if (input == 1) + { + int tmp = Player1.RollDie(&Die); + + cout << "Dice Rolled a: " << tmp << endl; + cout << "Running Score is: " << Player1.Get_TempScore() << endl; + cout << "Current Overall Score is: " << Player1.Get_Score() << endl; + } + else if (input == 2) + { + Player1.Set_Hold(true); + + cout << "New Overall Score: " << Player1.Get_Score() << endl; + } + } + + cout << endl; + + while (!Computer1.Get_Hold()) + { + cout << "Computers Rolls: " << Computer1.RollDie(&Die) << endl; + } + + cout << "Computers New Overall Score: " << Computer1.Get_Score() << endl; + + cout << endl; + + Player1.Set_Hold(false); + Computer1.Set_Hold(false); + } + + if (Player1.Get_Score() >= 100) + { + cout << "Player One is the winner!!!"; + } + else + { + cout << "The Computer is the winner!!!"; + } + cin.ignore(); + cin.get(); + + return 0; +} \ No newline at end of file diff --git a/Player.cpp b/Player.cpp new file mode 100644 index 0000000..c281471 --- /dev/null +++ b/Player.cpp @@ -0,0 +1,46 @@ +#include "Player.h" + +int Player::RollDie(Dice *Die) +{ + int RolledNumber = Die->RollDice(); + + if (RolledNumber == 1) + { + TempScore = 0; + Hold = true; + } + else + { + TempScore += RolledNumber; + } + return RolledNumber; +} + +bool Player::Get_Hold() +{ + return Hold; +} + +void Player::Set_Hold(bool toHold) +{ + if (toHold) + { + OverallScore += TempScore; + TempScore = 0; + Hold = toHold; + } + else + { + Hold = false; + } +} + +int Player::Get_Score() +{ + return OverallScore; +} + +int Player::Get_TempScore() +{ + return TempScore; +} \ No newline at end of file diff --git a/Player.h b/Player.h new file mode 100644 index 0000000..2f9c721 --- /dev/null +++ b/Player.h @@ -0,0 +1,26 @@ +#ifndef __PLAYER__ +#define __PLAYER__ + +#include "Dice.h" + +class Player +{ +protected: + int TempScore; + int OverallScore; + bool Hold; + +public: + + + Player() : TempScore(0), OverallScore(0), Hold(false) + {} + + virtual int RollDie(Dice *Die); //Roll of non 1 adds to TempScore, roll of 1: TempScore = 0 + bool Get_Hold(); + void Set_Hold(bool); + int Get_Score(); + int Get_TempScore(); +}; + +#endif \ No newline at end of file