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 aHealthReportrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of thehealthRemainingrecord component.intReturns the value of thescoreByHitrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
HealthReport
public HealthReport(int healthRemaining, int scoreByHit) Creates an instance of aHealthReportrecord class.- Parameters:
healthRemaining- the value for thehealthRemainingrecord componentscoreByHit- the value for thescoreByHitrecord 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 thehealthRemainingrecord component.- Returns:
- the value of the
healthRemainingrecord component
-
scoreByHit
public int scoreByHit()Returns the value of thescoreByHitrecord component.- Returns:
- the value of the
scoreByHitrecord component
-