Package net.royalur.model.dice
Record Class SimpleRoll
java.lang.Object
java.lang.Record
net.royalur.model.dice.SimpleRoll
- Record Components:
value
- The value of the dice roll.
- All Implemented Interfaces:
Roll
A roll of dice that contains just a value.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SimpleRoll
A constant representing a roll of four.static final SimpleRoll
A constant representing a roll of one.static final SimpleRoll
A constant representing a roll of three.static final SimpleRoll
A constant representing a roll of two.static final SimpleRoll
A constant representing a roll of zero. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates whether some other object is "equal to" this one.int
hashCode()
Returns a hash code value for this object.static SimpleRoll
of
(int value) Generates a roll representing a roll of the valuevalue
.toString()
Returns a string representation of this record class.int
value()
Gets the value of this dice roll.
-
Field Details
-
ZERO
A constant representing a roll of zero. -
ONE
A constant representing a roll of one. -
TWO
A constant representing a roll of two. -
THREE
A constant representing a roll of three. -
FOUR
A constant representing a roll of four.
-
-
Constructor Details
-
SimpleRoll
public SimpleRoll(int value) Instantiates a dice roll.- Parameters:
value
- The value of the roll.
-
-
Method Details
-
value
public int value()Gets the value of this dice roll. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
of
Generates a roll representing a roll of the valuevalue
.- Parameters:
value
- The value that was rolled on the dice.- Returns:
- A roll representing a roll of the value
value
.
-