Question: C++ need help on adding Dice object and adding a fuction to roll all the dices - here is my code (Yahtzee game) Player.h #ifndef

C++ need help on adding Dice object and adding a fuction to roll all the dices - here is my code (Yahtzee game)

Player.h

#ifndef PLAYER_H

#define PLAYER_H

#include "Dice.h"

class Player

{

private:

Dice myDice[5]; // an array of Dice objects

int nDice; // number of Dices player has

public:

Player(int nDice); // parameterized constructor with nDice

void playerRoll(); // roll all the dices

void setNumDice(int nDice); // set number of dices

int getDiceValueAtIndex(int i) const; // get value of Dice i

};

#endif

Player.cpp

#include "Player.h"

Player::Player(int number){

nDice = number;

for (int i = 0; i < nDice; i++){

Dice d1;

/*

add Dice object created to array of Dices

... is it Dice d1, d2(1,2,3,4,5)?

*/

}

}

void Player::setNumDice(int number){

nDice = number;

}

void Player::playerRoll(){

/*

Create a function to roll all the dices

*/

}

int Player::getDiceValueAtIndex(int i) const{

return myDice[i].getFaceValue();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!