Question: main.cpp #include #include Dice.h using namespace std; int main() { // Die will all be 0 until setSeed and rollDice called Dice d1; // 2

 main.cpp #include #include "Dice.h" using namespace std; int main() { //

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; }

Dice.h

//Dice class interface

#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__

Dice.cpp

// Dice class implementation file

Wchapter/5/section/14 10B: Introduction to Computer Science for Science, Mathematics & Engineering II home > am Problem 2 (Section 001) E zyBooks ca Program Secifications 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. You may not add or remove these. Figure out how to do this class with just those member variables. 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. 2997747659912 076 LAB ACTIVITY 5.14.1: Midterm Exam Problem 2 (Section 001) Load derault template Current file: main.cpp midterm 1 // Dice class test harness 2 3 #include 4 #include "Dice.h" 5 6 using namespace std; 7 8 int main() {

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!