Record Class Maze.Point

java.lang.Object
java.lang.Record
nz.ac.vuw.ecs.swen225.gp22.domain.Maze.Point
Enclosing class:
Maze

public static record Maze.Point(int x, int y) extends Record
Represents a point on the tilemap.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Point(int x, int y)
    Creates an instance of a Point record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(int addX, int addY)
    Overloaded method for add() that accepts two individual numbers that represent X and Y, respectively.
    Overloaded method for add() that accepts a Direction.
    add(Maze.Point point)
    Adds this point and another, then returns the result.
    boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    boolean
     
    subtract(int subtractX, int subtractY)
    Overloaded method for subtract() that accepts two individual numbers that represent X and Y, respectively.
    Overloaded method for subtract() that accepts a Direction.
    Subtract this point from another, then returns the result.
    final String
    Returns a string representation of this record class.
    int
    x()
    Returns the value of the x record component.
    int
    y()
    Returns the value of the y record component.

    Methods inherited from class java.lang.Object

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

    • Point

      public Point(int x, int y)
      Creates an instance of a Point record class.
      Parameters:
      x - the value for the x record component
      y - the value for the y record component
  • Method Details

    • add

      public Maze.Point add(Maze.Point point)
      Adds this point and another, then returns the result.
      Parameters:
      point - The point to add.
      Returns:
      Point object representing the sum of the two points.
    • add

      public Maze.Point add(Entity.Direction dir)
      Overloaded method for add() that accepts a Direction.
      Parameters:
      dir - Direction to get point from.
      Returns:
      Point object representing the sum of the point and direction.
    • add

      public Maze.Point add(int addX, int addY)
      Overloaded method for add() that accepts two individual numbers that represent X and Y, respectively.
      Parameters:
      addX - The amount to add to the X.
      addY - The amount to add to the Y.
      Returns:
      Point object representing the sum of the point and the two numbers.
    • subtract

      public Maze.Point subtract(Maze.Point point)
      Subtract this point from another, then returns the result.
      Parameters:
      point - Point to subtract by.
      Returns:
      Point object representing the result of the two points.
    • subtract

      public Maze.Point subtract(Entity.Direction dir)
      Overloaded method for subtract() that accepts a Direction.
      Parameters:
      dir - Direction to get point from.
      Returns:
      Point object representing the result of the point minus the direction.
    • subtract

      public Maze.Point subtract(int subtractX, int subtractY)
      Overloaded method for subtract() that accepts two individual numbers that represent X and Y, respectively.
      Parameters:
      subtractX - The amount to subtract from the X.
      subtractY - The amount to subtract from the Y.
      Returns:
      Point object representing the result of the point minus the two numbers.
    • isValid

      public boolean isValid()
      Returns:
      Whether or not the point exists on the tilemap.
    • hashCode

      public 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 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. All components in this record class 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.
    • 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
    • x

      public int x()
      Returns the value of the x record component.
      Returns:
      the value of the x record component
    • y

      public int y()
      Returns the value of the y record component.
      Returns:
      the value of the y record component