Question: I'm having a tough time with this, how do I divide this into 5 different files. I need Main.cpp, Die.h, Die.cpp, Player.h, Player.cpp #include using
I'm having a tough time with this, how do I divide this into 5 different files. I need Main.cpp, Die.h, Die.cpp, Player.h, Player.cpp
#include
class Die{ private: int sides; int face; public: Die(){ sides = 6; rollDice(); }
Die(int s){ sides = s; rollDice(); } void rollDice(){ face = rand()%sides+1; } int value(){ return face; } };
class Player{ private: string name; Die* dice; int total; public: Player(string n,int dc,int face){ name = n; total = dc; dice = new Die[dc]; for(int i=0;i } void roll(){ //role each dice for(int i=0;i void showRoll(){ //role each dice cout<<"DICE"< int getTotal(){ int totalCount=0; for(int i=0;i void reRoll(int index){ index--; if(index>=0 && index int main() { int diceCount; int face; string name; cout<<"Enter name of the player: "; cin>>name; cout<<"Enter number of dice : "; cin>>diceCount; cout<<"Enter face count for the dice : "; cin>>face; Player player(name,diceCount,face); player.roll(); player.showRoll(); while(true){ cout<<" how many dice do you want to re roll ? "; int reRollCount; cin>>reRollCount; if(reRollCount==0){ break; } int diceIndex; for(int i=1;i<=reRollCount;i++){ cout<<"Which dice to re roll ? "; cin>>diceIndex; player.reRoll(diceIndex); } player.showRoll(); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
