1. Using the Die class defined and modified in class, design and implement a class called PairOfDice, composed of two Die objects as instance data.
1. Using the Die class defined and modified in class, design and implement a class called PairOfDice, composed of two Die objects as instance data. The class should include the following methods: A non-default constructor, i.e. with parameters A setter method for each instance data A getter method for each instance data A method roll() that rolls both dice A toString() method that returns a string containing the colors of both dice, eg Colors of both dice: Red, Blue A method pairSum that returns the current sum of the two die values. A method equals() that compares two pairs of dice and returns true, if each pair contains dice with same color and face value. For example, if the first pair contains dice with color/faceValue: Red/5, Blue/3 and second pair contains dice with color/faceValue: Blue/3, Red/5, the method will return true. If the first pair contains dice with color/faceValue: Red/5, Blue/3 and second pair contains dice with color/faceValue: Blue/5, Red/5, the method will return false.
2. Write an application TestPairOfDice that uses the PairOfDice class to create two pair of dice. The application prints to the screen the sum of the face value of the dice inside the first pair. The program then rolls the second pair and prints to the screen the information about each pair. Lastly, the program to the screen whether the two pairs are equal or not.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image_2](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image_3](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started