Question: Given this UML. Must be done in python. I am stuck with implementing the methods portion. __init__ should initialize all class variables. It receives the

Given this UML. Must be done in python. I am stuck with implementing the methods portion.

Given this UML. Must be done in python. I am stuck with

__init__ should initialize all class variables. It receives the number of die sides as an argument or defaults to 6.

rollDie() this method rolls one die and returns the random value generated based on the number of sides of the die. A die with 3 sides can return 1, 2, or 3. A twenty-sided die can return values 1 to 20.

rollTwoDie() this method rolls 2 die and returns the total of both die added together.

rollMultiDie() this method receives the number of die to roll as an argument. The default value is 2 if no argument provided. It returns the total value of all die rolled.

getSides() returns the dies number of sides.

getDieCount() returns the total number of die instantiated.

incrementRolls() this is a utility method only used by the class itself. It is not part of the user interface. Its purpose is to increment totalRolls by 1 every time the die is rolled. If the total number of rolls exceeds 100, replaceDie is set to True.

getIncrementRolls() this method returns the totalRolls of the die.

resetIncrementRolls() this method resets totalRolls to 0.

replaceDie() this method returns the value of replaceDie.

Die -dieCount: int -numberOfSides: int -totalRolls: int -replaceDie: Boolean + _init_ (n = 6: int) +rollDie(): int +rollTwoDie(): int +rollMultiDie( n = 2: int): int +getSides(): int +getDieCount(): int -incrementRolls() +getlncrementRolls():int +resetlncrementRolls() +replaceDie(): Boolean

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!