__MACOSX/._files files/SampleOutput.txt [piotrj1@bobby test]$ ./a.out Please enter a seed: 221 221 Creating ThickSkin Player... P-0 Creating Survivor Player... P-1 Creating Genius Player... P-2 There...

I attached the instructions


__MACOSX/._files files/SampleOutput.txt [piotrj1@bobby test]$ ./a.out Please enter a seed: 221 221 Creating ThickSkin Player... P-0 Creating Survivor Player... P-1 Creating Genius Player... P-2 There are 3 total players! ||||||||||||||||||||||||||||||||||||| GAME START ||||||||||||||||||||||||||||||||||||| ************************************ *** ROUND 0 ************************************ ------------------ P-0 is rolling a die... ... it is a 5 ------------------ P-1 is rolling a die... ... it is a 5 ------------------ P-2 is rolling a die... ... it is a 6 ------------------ Recording Losses... P-0 lost that round. P-1 lost that round. ************************************ ************************************ *** ROUND 1 ************************************ ------------------ P-0 is rolling a die... ... it is a 2 ------------------ P-1 is rolling a die... ... it is a 2 ------------------ P-2 is rolling a die... ... it is a 1 ------------------ Recording Losses... P-2 lost that round. ************************************ ************************************ *** ROUND 2 ************************************ ------------------ P-0 is rolling a die... ... it is a 1 ------------------ P-1 is rolling a die... ... it is a 6 ------------------ P-2 is rolling a die... ... it is a 1 ------------------ Recording Losses... P-0 lost that round. P-2 lost that round. ************************************ ************************************ *** ROUND 3 ************************************ ------------------ P-0 is rolling a die... ... it is a 2 ------------------ P-1 is rolling a die... ... it is a 6 ------------------ *Special Invoked!* - P-2 added 2 to thier dice roll! P-2 is rolling a die... ... it is a 7 ------------------ Recording Losses... P-0 lost that round. P-1 lost that round. *Special Invoked!* - P-1 survived for one more round! ************************************ ************************************ *** ROUND 4 ************************************ ------------------ P-0 is rolling a die... ... it is a 5 ------------------ P-1 is rolling a die... ... it is a 4 ------------------ P-2 is rolling a die... ... it is a 2 ------------------ Recording Losses... P-1 lost that round. *Special Invoked!* - P-1 survived for one more round! P-2 lost that round. P-2 is out of the game! ************************************ ************************************ *** ROUND 5 ************************************ ------------------ P-0 is rolling a die... ... it is a 2 ------------------ P-1 is rolling a die... ... it is a 3 ------------------ Recording Losses... P-0 lost that round. P-0 is out of the game! ************************************ P-1 wins! [piotrj1@bobby test]$ __MACOSX/files/._SampleOutput.txt files/Player.cpp #ifndef Player_H #define Player_H #include "Player.h" #endif using namespace std; /******************************* * Player Class *******************************/ int Player::PlayerCount = 0; Player::Player() : numTurns(3), PlayerID("P-" + to_string(PlayerCount)){ PlayerCount += 1; } Player::Player(int nt) : numTurns(nt), PlayerID("P-" + to_string(PlayerCount)){ PlayerCount += 1; } Player::~Player(){ PlayerCount -= 1; } bool Player::StillPlaying() const{ return (numTurns > 0); } int Player::RollDice() const{ return ((StillPlaying()) ? ((rand() % 6) + 1) : 0); } void Player::RecordLoss(){ if(numTurns > 0){ numTurns -= 1; if(numTurns == 0){ cout < playerid="">< "="" is="" out="" of="" the="" game!"="">< endl;="" }="" }="" }="" bool="" player::chanceforspecialpower(){="" return="" ((rand()="" %="" 100)="">< 5);="" }="" string="" player::getpid()="" const{="" return="" playerid;="" }="" int="" player::getplayercount(){="" return="" playercount;="" }="" *******************************="" *="" thickskin="" class="" *******************************/="" your="" code="" goes="" here="" *******************************="" *="" survivor="" class="" *******************************/="" your="" code="" goes="" here="" *******************************="" *="" genius="" class="" *******************************/="" your="" code="" goes="" here="" ***************************="" *="" global="" functions="" ***************************/="" bool="" playgame(player&="" t,="" player&="" s,="" player&="" g,="" int="" round){="" int="" check="0;" check="" +="t.StillPlaying();" check="" +="s.StillPlaying();" check="" +="g.StillPlaying();" if(check="=" 1){="" if(t.stillplaying()){="" cout="">< "="" wins!"="">< endl;="" }="" else="" if(s.stillplaying()){="" cout="">< s.getpid()="">< "="" wins!"="">< endl;="" }="" else="" if(g.stillplaying()){="" cout="">< "="" wins!"="">< endl;="" }="" return="" false;="" }="" cout="">< "************************************"="">< endl="">< "***="" round="" "="">< round="">< endl="">< "************************************"="">< endl;="" roll="" the="" dice="" int="" tdice,="" sdice,="" gdice;="" cout="">< "------------------"="">< endl;="" tdice="t.RollDice();" if(tdice=""> 0){ cout < t.getpid()="">< "="" is="" rolling="" a="" die...="" "="">< endl;="" cout="">< "="" ...="" it="" is="" a="" "="">< tdice="">< endl;="" cout="">< "------------------"="">< endl;="" }="" sdice="s.RollDice();" if(sdice=""> 0){ cout < s.getpid()="">< "="" is="" rolling="" a="" die...="" "="">< endl;="" cout="">< "="" ...="" it="" is="" a="" "="">< sdice="">< endl;="" cout="">< "------------------"="">< endl;="" }="" gdice="g.RollDice();" if(gdice=""> 0){ cout < g.getpid()="">< "="" is="" rolling="" a="" die...="" "="">< endl;="" cout="">< "="" ...="" it="" is="" a="" "="">< gdice="">< endl;="" cout="">< "------------------"="">< endl;="" }="" cout="">< "recording="" losses..."="">< endl;="" find="" the="" winner="" int="" maxdie="tDice;" if(maxdie="">< sdice){="" maxdie="sDice;" }="" if(maxdie="">< gdice){="" maxdie="gDice;" }="" record="" the="" losses="" if(tdice="">< maxdie="" &&="" tdice=""> 0){ cout < t.getpid()="">< "="" lost="" that="" round."="">< endl;="" t.recordloss();="" }="" if(sdice="">< maxdie="" &&="" sdice=""> 0){ cout < s.getpid()="">< "="" lost="" that="" round."="">< endl;="" s.recordloss();="" }="" if(gdice="">< maxdie="" &&="" gdice=""> 0){ cout < g.getpid()="">< "="" lost="" that="" round."="">< endl;="" g.recordloss();="" }="" cout="">< "************************************"="">< endl;="" return="" true;="" }="" __macosx/files/._player.cpp="" files/player.h="" #ifndef="" ios_h="" #define="" ios_h="" #include=""> #include #endif #ifndef RAND_H #define RAND_H #include #endif using namespace std; /******************************* * Player Class *******************************/ class Player{ private: int numTurns; static int PlayerCount; string PlayerID; public: Player(); Player(int); ~Player(); bool StillPlaying() const; int RollDice() const; void RecordLoss(); static bool ChanceForSpecialPower(); string GetPID() const; static int GetPlayerCount(); }; /******************************* * ThickSkin Class *******************************/ //YOUR CODE GOES HERE /******************************* * Survivor Class *******************************/ //YOUR CODE GOES HERE /******************************* * Genius Class *******************************/ //YOUR CODE GOES HERE /******************************* * Global Functions *******************************/ bool PlayGame(Player&, Player&, Player&, int); __MACOSX/files/._Player.h files/Main.cpp #ifndef Player_H #define Player_H #include "Player.h" #endif #ifndef IOS_H #define IOS_H #include #include #endif #ifndef RAND_H #define RAND_H #include #endif using namespace std; int main(){ unsigned long long seed; // = time(NULL); cout < "please="" enter="" a="" seed:="" ";="" cin="">> seed; cout < seed="">< endl;="" srand="" (seed);="" makes="" things="" more="" random="" int="" rounds="0;" cout="">< "creating="" player...="" ";="" player="" p1;="" cout="">< p1.getpid()="">< endl;="" cout="">< "creating="" player...="" ";="" player="" p2;="" cout="">< p2.getpid()="">< endl;="" cout="">< "creating="" player...="" ";="" player="" p3;="" cout="">< p3.getpid()="">< endl;="" cout="">< "there="" are="" "="">< player::getplayercount()="">< "="" total="" players!"="">< endl;="" cout="">< "|||||||||||||||||||||||||||||"="">< "||||||||="" game="" start="" ||||||||"="">< "|||||||||||||||||||||||||||||"="">< endl; while(playgame(p1,p2,p3,rounds)){ rounds++; } return 0; } __macosx/files/._main.cpp endl;="" while(playgame(p1,p2,p3,rounds)){="" rounds++;="" }="" return="" 0;="" }="">
Aug 09, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here