Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions