subject

Using the Die class provided design and implement a class called PairOfDice, composed of two Die objects. Include methods to set and get the individual die values, a method to roll the dice, and a method that returns the current sum of the two die values. Create a driver class called RollingDice2 to instantiate and use a PairOfDice object. Here is the Die class:import java. util. Random;/** The Die class simulates a six-sided die.*/public class Die{ private int sides; // Number of sides private int value; // The die's value /** The constructor performs an initial roll of the die. @param numSides The number of sides for this die. */ public Die(int numSides) { sides = numSides; roll(); } /** The roll method simlates the rolling of the die. */ public void roll() { // Create a Random object. Random rand = new Random(); // Get a random value for the die. value = rand. nextInt(sides) + 1; } /**getSides method @return The number of sides for this die. */ public int getSides() { return sides; } /**getValue method @return The value of the die. */ public int getValue() {return value; }

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:30, reinasuarez964
One of your customers wants you to build a personal server that he can use in his home. one of his concerns is making sure he has at least one backup of their data stored on the server in the event that a disk fails. you have decided to back up his data using raid. since this server is for personal use only, the customer wants to keep costs down. therefore, he would like to keep the number of drives to a minimum. which of the following raid systems would best meet the customer's specifications? a. raid 0 b. raid 1 c. raid 5 d. raid 10
Answers: 3
image
Computers and Technology, 23.06.2019 06:30, eddsworldfrantic
You have a small company and want to keep your costs low, but it is important your employees share data. which network would provide you with the most economical solution?
Answers: 1
image
Computers and Technology, 23.06.2019 15:20, headshotplayzcod
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, bellamyciana
What are two ways to access the options for scaling and page orientation? click the home tab, then click alignment, or click the file tab. click the file tab, then click print, or click the page layout tab. click the page layout tab, or click the review tab. click the review tab, or click the home tab?
Answers: 2
You know the right answer?
Using the Die class provided design and implement a class called PairOfDice, composed of two Die obj...

Questions in other subjects: