Question: C++ I need help creating classes that roll dice in C++: there will be two classes, one for a single die and another class for

C++

I need help creating classes that roll dice in C++: there will be two classes, one for a single die and another class for a set of dice. The dice class will contain two instances of the die class as private member variables.

The general functionality of each class is as follows:

Dice:

A two-element array of type class die (and whatever other variables you need)

Method for rolling the dice (technically this is a mutator)

Accessor for the value of the entire roll (should return -1 if the roll on either die is invalid)

Accessor for each die individually

Die:

Private member variable to hold the last roll

Seed the random number generator and initialize the roll to -1 in the constructor

Accessor to get the last roll

Method for rolling the die (technically a mutator)

The main function should create a Dice variable, roll it and show the results (for each die and for the entire roll) a couple of times.

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!