Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Dice are used in many tabletop games to implement various game mechanics. Dice come in a variety of shapes and sizes, with four, six, eight,
Dice are used in many tabletop games to implement various game mechanics. Dice come in a variety of shapes and sizes, with four, six, eight, ten, twelve, or twenty sides. Many games need you to assemble a collection of differentsized dice and roll them together. Create a program to imitate dice for a tabletop game.
Create a class for a single dice. The constructor should accept an integer that indicates how many sides the die has. The class should include a function that simulates rolling the die and returns a random number from the valid range.
Create another class that represents a pool of dice. This class should include functions for adding or removing a die from the pool. The class should also include a function that rolls all of the dice in the pool and returns the total that was rolled.
All commands
add
add
roll
roll
add
roll
roll
roll
rollall
add
add
remove
rollall
remove
remove
remove
add
rollall
Exit
Sample inputoutput:
Enter Command:
add
Adding Dice
Enter Command:
add
Adding Dice
Enter Command:
roll
Dice Roll Result:
Enter Command:
roll
Dice Roll Result:
Enter Command:
add
Adding Dice
Enter Command:
roll
Dice Roll Result:
Enter Command:
roll
Dice Roll Result:
Enter Command:
roll
Dice Roll Result:
Enter Command:
rollall
Rolling all Dice:
Dice : Roll Result:
Dice : Roll Result:
Dice : Roll Result:
Summation of all rolls:
Enter Command:
add
Adding Dice
Enter Command:
add
Adding Dice
Enter Command:
remove
Removing Dice
Remove Successful: True
Enter Command:
rollall
Rolling all Dice:
Dice : Roll Result:
Dice : Roll Result:
Dice : Roll Result:
Dice : Roll Result:
Summation of all rolls:
Enter Command:
remove
Removing Dice
Remove Successful: True
Enter Command:
remove
Removing Dice
Remove Successful: True
Enter Command:
remove
Removing Dice
Remove Successful: False
Enter Command:
add
Adding Dice
Enter Command:
rollall
Rolling all Dice:
Dice : Roll Result:
Dice : Roll Result:
Dice : Roll Result:
Summation of all rolls:
Enter Command:
Exit
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started