Package battleship.model.game
Record Class HealthReport
java.lang.Object
java.lang.Record
battleship.model.game.HealthReport
Health report (contains ship health remaining, and power of attack).
-
Constructor Summary
ConstructorsConstructorDescriptionHealthReport
(int healthRemaining, int scoreByHit) Creates an instance of aHealthReport
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.int
Returns the value of thehealthRemaining
record component.int
Returns the value of thescoreByHit
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
HealthReport
public HealthReport(int healthRemaining, int scoreByHit) Creates an instance of aHealthReport
record class.- Parameters:
healthRemaining
- the value for thehealthRemaining
record componentscoreByHit
- the value for thescoreByHit
record component
-
-
Method Details
-
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. -
hashCode
public final 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 '=='. -
healthRemaining
public int healthRemaining()Returns the value of thehealthRemaining
record component.- Returns:
- the value of the
healthRemaining
record component
-
scoreByHit
public int scoreByHit()Returns the value of thescoreByHit
record component.- Returns:
- the value of the
scoreByHit
record component
-