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.MazeEdge
The field for theedge
record component.private final double
The field for theprogress
record component. -
Constructor Summary
ConstructorsConstructorDescriptionLocation
(MazeGraph.MazeEdge edge, double progress) Creates an instance of aLocation
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
atVertex()
Return whether this actor's location represents standing atop a vertex (which is true when progress is 0 or 1).boolean
collidesWith
(Actor.Location other) Determines whether this location and the given `other` location have collided.edge()
Returns the value of theedge
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Return the nearest vertex to this actor, depending on their progress along the current edge.double
progress()
Returns the value of theprogress
record 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 String
toString()
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 theedge
record component.- Returns:
- the value of the
edge
record component
-
progress
public double progress()Returns the value of theprogress
record component.- Returns:
- the value of the
progress
record component
-