Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**DICE.H file ** #ifndef __DICE_H__ #define __DICE_H__ #include #include #include using namespace std; class Dice { private: int _numSides; vector _latestRoll; public: /* Default number

image text in transcribed

**DICE.H file **

#ifndef __DICE_H__ #define __DICE_H__

#include #include #include using namespace std;

class Dice { private: int _numSides; vector _latestRoll; public: /* Default number of dice is 2. * Default number of sides is 6. * * Side values always start at 1. * For example, a 6-sided die would have the values * 1 2 3 4 5 6 on its sides. * * Can use vector's resize function * to resize the vector to the appropriate size. */ Dice(int = 2, int = 6); /* Uses srand() to set the seed of the rand() function. */ void setSeed(int); /* Gets random values for all dice and stores them in _latestRoll */ void rollDice(); /* Returns the total of all dice from latest roll */ int rollTotal() const; /* Outputs all dice with a space between them * and no space or newline at the end */ friend ostream & operator

#endif // __DICE_H__

Main.CPP:

#include #include "Dice.h"

using namespace std;

int main() { // Die will all be 0 until setSeed and rollDice called Dice d1; // 2 6-sided dice cout

// Dice d3 = Dice(4, 20); // 4 20-sided dice // d3.setSeed(101110); // d3.rollDice(); // cout

return 0; }

Implement a Dice class. 1. The required Dice member function declarations (interface) have already been included in the Dice.h file. Do not change these. Do not add any other public member functions. 2. The private member variables have been provided as well. Feel free to remove any you don't use or add any if you want. You may also change their names if you want. 3. You must implement all functions in the Dice.cpp file. 4. You should uncomment statements in the main function as you implement the member functions contained within each statement. These are there to help you understand what each function does as well as test them. You will need to eventually uncomment all statements to pass all feedback output tests. 5. You will also need to implement an overloaded output (insertion) operator (already declared within the Dice.h file). You will want to do this early so that you can test your results as you go. 6. The specifications for each member function is provided in the Dice h file. Implement a Dice class. 1. The required Dice member function declarations (interface) have already been included in the Dice.h file. Do not change these. Do not add any other public member functions. 2. The private member variables have been provided as well. Feel free to remove any you don't use or add any if you want. You may also change their names if you want. 3. You must implement all functions in the Dice.cpp file. 4. You should uncomment statements in the main function as you implement the member functions contained within each statement. These are there to help you understand what each function does as well as test them. You will need to eventually uncomment all statements to pass all feedback output tests. 5. You will also need to implement an overloaded output (insertion) operator (already declared within the Dice.h file). You will want to do this early so that you can test your results as you go. 6. The specifications for each member function is provided in the Dice h file

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

How will you measure it?

Answered: 1 week ago

Question

LO4 List options for development needs analyses.

Answered: 1 week ago