Question: Problem 1 . ( Die Data Type ) Implement a comparable data type called Die that represents a six - sided die and supports the

Problem 1.(Die Data Type) Implement a comparable data type called Die that represents a six-sided die and supports the following API:
2 Die
Die() constructs a die with the face value -1
void roll() rolls this die
int value() returns the face value of this die
boolean equals(Die other) returns true if this die is the same as other, and false otherwise
String toString() returns a string representation of this die
int compareTo(Die other) returns a comparison of this die and other based on their face values
& ~/workspace/autocomplete
$ javac -d out $ java Die Dice a, b, and *
*
*
*****
*
*
* a.equals(b)
a.equals(c) a.compareTo(b) a.compareTo(c)
src/Die.java c:
= false = true =-1
=0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!