Record Class Ship
java.lang.Object
java.lang.Record
com.alessiocascini.battleship.client.model.Ship
- Record Components:
info- TheShipInfocontaining name and sizecells- An array ofCellobjects representing the ship's position
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCell[]cells()Returns the value of thecellsrecord component.final booleanIndicates whether some other object is "equal to" this one.int[][]Converts the ship's cell coordinates into a primitive 2D integer array.final inthashCode()Returns a hash code value for this object.info()Returns the value of theinforecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Ship
-
-
Method Details
-
getCellsAsArray
public int[][] getCellsAsArray()Converts the ship's cell coordinates into a primitive 2D integer array. This format is typically used for network transmission to the server.- Returns:
- A 2D array where each element is a [row, col] pair
-
toString
-
hashCode
-
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 withObjects::equals(Object,Object). -
info
-
cells
-