Record Class AxialPosition
java.lang.Object
java.lang.Record
spinhex.model.AxialPosition
- Record Components:
q
- The row coordinates
- The top-left to bottom-right diagonal coordinate
Represents a position in an axial coordinate system for a hexagonal grid.
In axial coordinates, the position is described by two values, q and s, where q represents the row and s represents the top-left to bottom-right diagonal.
To learn more about axial coordinates, refer to: Red Blob Games - Axial Coordinates-
Constructor Summary
ConstructorsConstructorDescriptionAxialPosition
(int q, int s) Creates an instance of aAxialPosition
record class. -
Method Summary
Modifier and TypeMethodDescriptionadd
(AxialPosition other) Adds another axial position to this one.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.int
q()
Returns the value of theq
record component.int
s()
Returns the value of thes
record component.subtract
(AxialPosition other) Subtracts another axial position from this one.toString()
Returns a string representation of this position in the format "(q,s)".
-
Constructor Details
-
AxialPosition
-
-
Method Details
-
toString
-
add
Adds another axial position to this one.- Parameters:
other
- The axial position to add- Returns:
- A new axial position representing the sum
-
subtract
Subtracts another axial position from this one.- Parameters:
other
- The axial position to subtract- Returns:
- A new axial position representing the difference
-
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 with thecompare
method from their corresponding wrapper classes. -
q
-
s
-