Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

During the second world war, the top federal tax rate climbed to

Answered: 1 week ago