Design a PairOfDice class that models two standard six-sided die. Your PairOfDic
ID: 3633799 • Letter: D
Question
Design a PairOfDice class that models two standard six-sided die. Your PairOfDice class should provide the following:-A constructor PairOfDice() that allows an object of class PairOfDice to be instantiated. The constructor should set the original "value" of each die to 1
-a roll method that "rolls" each of the dice and returns the total value
-a total method that returns the total value of the dice
-a value1 method that returns the value of the "first" die
-a value2 method that returns the value of the "second" die
Explanation / Answer
Hope this helps, please rate! public class PairOfDice { public int side1; public int side2; public PairOfDice(){ side1 = 1; side2 = 1; } public void roll(){ side1 = (int) (Math.random()*6); side2 = (int) (Math.random()*6); } public int total(){ return side1 + side2; } public int getSide1(){ return side1; } public int getSide2(){ return side2; } public static void main(String[] args) { PairOfDice lucky = new PairOfDice(); System.out.println("Initial dice: " + lucky.getSide1()+" "+lucky.getSide2()); lucky.roll(); System.out.println("Dice after roll: " + lucky.getSide1()+" "+lucky.getSide2()); System.out.println("Total of dice after roll: " + lucky.total()); } }