Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this lab you will write three classes: Die, PairOfDice, and Player. The Die class mimics the rolling of a die. Specifically, this class will
In this lab you will write three classes: Die, PairOfDice, and Player. The Die class mimics the rolling of a die. Specifically, this class will implement the following methods: A default constructor initializing the number of sides of a die to 6. An overloaded constructor that takes an integer number of sides (assume greater than 1) roll which generates and returns a random number between 1 and the number of sides (inclusive) An accessor method to read the value of the face on the die. A toString method returning the string representation of the face value. The maximum number of sides should be stored as a private constant in the Die class. Also use the Random class for the random number generator The PairOfDice class mimics the rolling of two dice. Specifically, this class will implement the following methods: A default constructor that creates and initializes the number of sides of each die to 6. An overloaded constructor that creates and takes two integer number of sides, one for each die. roll rolls each die and returns the sum. An accessor method to read the sum of the dice. The Player class implements the main method which creates the dice pair and rolls them several times reporting the results
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