Record Class Coordinate
java.lang.Object
java.lang.Record
com.expedient.adventofcodejade.common.Coordinate
- Record Components:
row-col-
Represents a row, col Coordinate on a 2D array
-
Constructor Summary
ConstructorsConstructorDescriptionCoordinate(int row, int col) Creates an instance of aCoordinaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcol()Returns the value of thecolrecord component.doubledistance(Coordinate other) Finds the Euclidean distance between this coordinate and anotherfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.inOppositeDirection(Coordinate other) Provided other Coordinate, returns another Coordinate that's on the opposite side of this one from the secondbooleanisOrthogonal(Coordinate other) Determines whether this Coordinate is orthogonal to anothernextInDirection(Coordinate other) Provided a Coordinates, returns another Coordinate that's one additional step in the same direction from this oneintrow()Returns the value of therowrecord component.inttaxiCabDistance(Coordinate other) Finds the taxicab distance between this coordinate and anothertopLeft()topRight()final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Coordinate
-
-
Method Details
-
nextInDirection
Provided a Coordinates, returns another Coordinate that's one additional step in the same direction from this one- Parameters:
other- Ending Coordinate- Returns:
- Coordinate that continues in a line out from the second
-
inOppositeDirection
Provided other Coordinate, returns another Coordinate that's on the opposite side of this one from the second- Parameters:
other- Ending Coordinate- Returns:
- Coordinate one step from the first in the opposite direction
-
isOrthogonal
Determines whether this Coordinate is orthogonal to another- Parameters:
other- the other coordinate- Returns:
- whether they're orthogonal
-
taxiCabDistance
Finds the taxicab distance between this coordinate and another- Parameters:
other- the other coordinate- Returns:
- the taxicab distance between the two
-
directionToCoordinate
-
distance
Finds the Euclidean distance between this coordinate and another- Parameters:
other- the other coordinate- Returns:
- the Euclidean distance between the two coordinates
-
topLeft
-
topCenter
-
topRight
-
centerRight
-
bottomRight
-
bottomCenter
-
bottomLeft
-
centerLeft
-
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 with thecomparemethod from their corresponding wrapper classes. -
row
-
col
-