Package model
Record Class Actor.Location
java.lang.Object
java.lang.Record
model.Actor.Location
- Record Components:
edge- The current (or most recent if the character is stopped) edge that this actor is traversing.progress- The proportion of the `edge` that the actor has traversed. Requires `progress` is between 0 and 1 (inclusive): 0 denotes the start of the edge and 1 denotes the end of the edge.
- Enclosing class:
Actor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MazeGraph.MazeEdgeThe field for theedgerecord component.private final doubleThe field for theprogressrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionLocation(MazeGraph.MazeEdge edge, double progress) Creates an instance of aLocationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanatVertex()Return whether this actor's location represents standing atop a vertex (which is true when progress is 0 or 1).booleancollidesWith(Actor.Location other) Determines whether this location and the given `other` location have collided.edge()Returns the value of theedgerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Return the nearest vertex to this actor, depending on their progress along the current edge.doubleprogress()Returns the value of theprogressrecord component.progressed(double deltaProgress) Return a new Location object reflecting the given amount of progress being made along the current edge.reversed()Return a new Location object reflecting the actor having turned around at the same position on the board.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
Constructor Details
-
Method Details
-
nearestVertex
Return the nearest vertex to this actor, depending on their progress along the current edge. When their progress is less than 0.5, the `edge.src()` is returned. Otherwise, `edge.dst()` is returned. -
progressed
Return a new Location object reflecting the given amount of progress being made along the current edge. -
collidesWith
Determines whether this location and the given `other` location have collided. -
atVertex
public boolean atVertex()Return whether this actor's location represents standing atop a vertex (which is true when progress is 0 or 1). -
reversed
Return a new Location object reflecting the actor having turned around at the same position on the board. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
edge
Returns the value of theedgerecord component.- Returns:
- the value of the
edgerecord component
-
progress
public double progress()Returns the value of theprogressrecord component.- Returns:
- the value of the
progressrecord component
-