Many games are played with dice, known as a die in the singular. A die is a six-sided cube whose sides are labeled with one to six dots. The side that faces up indicates the die’s face value. Define a...


Many games are played with dice, known as a die in the singular. A die is a six-sided cube whose sides are labeled with one to six dots. The side that faces up indicates the die’s face value. Define a class Die that represents one n-sided die. The default value for n is 6. You should be able to roll the die and discover the value of its upper face. Thus, give thenclass the method roll, which returns a random integer ranging from 1 to n, and the method getFaceValue, which returns the current face value of the die. Note that a call to roll will return the same value as a subsequent call to getFaceValue. Demonstrate your class by creating several Die objects and rolling them.


Often, games depend on the roll of two dice. Using your class Die, create a class TwoDice. An object of TwoDice represents two six-sided dice that are rolled together. Include at least the following methods: rollDice, getFaceValueDieOne, getFaceValueDieTwo, isMatchingPair, isSnakeEyes, toString, and getValueOfDice, which returns the sum of the two upper faces. Demonstrate your class by creating a TwoDice object and rolling it several times.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here