Question: Die Write a 'Die' (singular form of dice) class that defines the behavior of a single die. Your class must have the following methods. Use
Die
Write a 'Die' (singular form of dice) class that defines the behavior of a single die. Your class must have the following methods. Use the template below as a starting point.
- A constructor that accepts an integer representing the number of sides on the die. For example 20 for a 20-sided die, 6 for a 6-sided die and so on.
- roll - returns a random number representing the result of rolling the die. For example; for a 6-sided die; 1, 2, 3, 4, 5 or 6
- rollMultiple(number) - Rolls the die number of times and returns a list object containing the resulting numbers
- getSides() - returns the number of sides on the die

Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
