Question: JAVA Die Write a Die class to model a die (like you play Yahtzee or Monopoly with). Fields int sides The number of sides on
JAVA
Die
Write a Die class to model a die (like you play Yahtzee or Monopoly with).
Fields
int sides The number of sides on the die.
int value The last rolled value (generated by the roll() method).
Methods
Die(int numSides) Constructor
int roll() returns a random number between 1 and numSides (inclusive)
void lick() Prints "You licked a die." to the screen.
String toString() returns the string version of a die; Example: "[d6] 3" where 6 is the number of sides and 3 is the value.
DieSet
Write another class named DiceSet that contains a set of Die objects.
Fields
private ArrayList
Methods
DiceSet() The constructor shoud instantiate the dice ArrayList.
Die removeDie(int value) Remove the first die with the given value.
void addDie(Die d) Adds the given die to the dice ArrayList.
int roll() Roll all the die objects in the ArrayList of dice.
void lick() Lick all the die objects in the ArrayList of dice.
ArrayList dieValues() Return an Integer of all of the values (last rolls) of the dice.
String toString() returns a string version of a dice set. Example: "{[d3] 1, [d6] 4, [d12] 5, [d4] 3}"
must include 3 methods (DiceSet.java, Main.java, and Dice.java)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
