Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview For this assignment, implement and use the methods for a class called Die. Overview For this assignment, implement and use the methods for a

Overview
For this assignment, implement and use the methods for a class called Die. image text in transcribed
image text in transcribed
Overview For this assignment, implement and use the methods for a class called Die. Die class The Die class is used to represent a 6-sided die. Data Members The class contains two data members An integer that holds the value of the side of the die that is up An integer symbolic constant that holds the maximum number of sides on the die. Use a value of 6. C++ 11 allows for symbolic constants to be initialized in the class definition. However, it's not something that is supported by all compilers because class definitions are treated as patterns for what the class should contain, and therefore, they don't take up any memory. To create a symbolic constant that will work for all compilers: 1. In the class definition, define the symbolic constant with the keyword "static" before the definition. So: static const int NUM SIDES 2. Before main, initialize the symbolic constant with its value. So: const int Die: NUM SIDES 6 Note the dropping of the keyword "static" and the inclusion of the "Die::" in front of the constant name. This lets the compiler know that the constant belongs to the Die class. Now, NUM_SIDES can be used in the class methods when needed. Constructor This class has one constructor, a default constructor (ie. one that takes no arguments). It should simply call the roll method that is described below to initialize the value of the side of the die that is up

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

Address an envelope properly.

Answered: 1 week ago

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago