Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python2.7 1. (20 points) Implement the DiceShaker class. The DiceShaker uses the Die class. This class allows you do roll multiple dice at the same
python2.7
>>>ds DiceShaker) >>>str (ds) >>>ds.shake) >>>ds.getTotalRoll () 1 >>str (ds) >>>ds.getIndividualRolls () 1. (20 points) Implement the DiceShaker class. The DiceShaker uses the Die class. This class allows you do roll multiple dice at the same time and get the individual rolls or a count of all the rolls.
a. init () takes two optional parameters. First parameter is the total dice in the shaker (default 1) and how many sides each of the die has (default =6)
b. shake() : Goes through all the Die stored in the shaker and calls the roll method on them.
c. getTotalRoll() : returns a integer of the total of all dice in the shaker. You must call the get() method on each die in the shaker.
d. getIndividualRolls() : returns a list of integer values that represent the face of all the dice in the shaker. You must call get on each of the dice in the shaker to put together the list.
e. str (): Displays the string value of each of the current values of the dice. Must be obtained using the get() method of each Die.
The following shows how the DiceShaker class and methods could be used:
class DiceShaker(object):
'DiceShaker class'
def __init__(self,dieCount=1, dieSides=6):
'initialize a dice shaker'
pass
def shake(self):
'shake all the dice in the shaker'
pass
def getTotalRoll(self):
'get the total face value of all the dice'
pass
def getIndividualRolls(self):
'get a lsit of integers of all the individual die rolls'
pass
def __str__(self):
'get a string with all the die rolls seperated by a space'
pass
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