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

public static record Actor.Location(MazeGraph.MazeEdge edge, double progress) extends Record
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final MazeGraph.MazeEdge
    The field for the edge record component.
    private final double
    The field for the progress record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Location(MazeGraph.MazeEdge edge, double progress)
    Creates an instance of a Location record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Return whether this actor's location represents standing atop a vertex (which is true when progress is 0 or 1).
    boolean
    Determines whether this location and the given `other` location have collided.
    Returns the value of the edge record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Return the nearest vertex to this actor, depending on their progress along the current edge.
    double
    Returns the value of the progress record component.
    progressed(double deltaProgress)
    Return a new Location object reflecting the given amount of progress being made along the current edge.
    Return a new Location object reflecting the actor having turned around at the same position on the board.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • edge

      private final MazeGraph.MazeEdge edge
      The field for the edge record component.
    • progress

      private final double progress
      The field for the progress record component.
  • Constructor Details

    • Location

      public Location(MazeGraph.MazeEdge edge, double progress)
      Creates an instance of a Location record class.
      Parameters:
      edge - the value for the edge record component
      progress - the value for the progress record component
  • Method Details

    • nearestVertex

      public MazeGraph.MazeVertex 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

      public Actor.Location progressed(double deltaProgress)
      Return a new Location object reflecting the given amount of progress being made along the current edge.
    • collidesWith

      public boolean collidesWith(Actor.Location other)
      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

      public Actor.Location reversed()
      Return a new Location object reflecting the actor having turned around at the same position on the board.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • edge

      public MazeGraph.MazeEdge edge()
      Returns the value of the edge record component.
      Returns:
      the value of the edge record component
    • progress

      public double progress()
      Returns the value of the progress record component.
      Returns:
      the value of the progress record component