Record Class RobotState
java.lang.Object
java.lang.Record
za.co.wethinkcode.robots.server.serverRobot.RobotState
- Record Components:
position- where the robot isdirection- what direction the robot is facingshields- how many shields the robot hasshots- how many shots the robot has leftstatus- what status the robot is in
public record RobotState(Position position, Direction direction, Integer shields, Integer shots, RobotStatus status)
extends Record
Record class for capturing a Robot's state
-
Constructor Summary
ConstructorsConstructorDescriptionRobotState(Position position, Direction direction, Integer shields, Integer shots, RobotStatus status) Creates an instance of aRobotStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thedirectionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.position()Returns the value of thepositionrecord component.shields()Returns the value of theshieldsrecord component.shots()Returns the value of theshotsrecord component.status()Returns the value of thestatusrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
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 withObjects::equals(Object,Object). -
position
Returns the value of thepositionrecord component.- Returns:
- the value of the
positionrecord component
-
direction
Returns the value of thedirectionrecord component.- Returns:
- the value of the
directionrecord component
-
shields
Returns the value of theshieldsrecord component.- Returns:
- the value of the
shieldsrecord component
-
shots
Returns the value of theshotsrecord component.- Returns:
- the value of the
shotsrecord component
-
status
Returns the value of thestatusrecord component.- Returns:
- the value of the
statusrecord component
-