Record Class Maze.Point
java.lang.Object
java.lang.Record
nz.ac.vuw.ecs.swen225.gp22.domain.Maze.Point
- Enclosing class:
- Maze
Represents a point on the tilemap.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(int addX, int addY) Overloaded method for add() that accepts two individual numbers that represent X and Y, respectively.add(Entity.Direction dir) Overloaded method for add() that accepts a Direction.add(Maze.Point point) Adds this point and another, then returns the result.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.booleanisValid()subtract(int subtractX, int subtractY) Overloaded method for subtract() that accepts two individual numbers that represent X and Y, respectively.subtract(Entity.Direction dir) Overloaded method for subtract() that accepts a Direction.subtract(Maze.Point point) Subtract this point from another, then returns the result.final StringtoString()Returns a string representation of this record class.intx()Returns the value of thexrecord component.inty()Returns the value of theyrecord component.
-
Constructor Details
-
Point
public Point(int x, int y) Creates an instance of aPointrecord class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord component
-
-
Method Details
-
add
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
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
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
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
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
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. -
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 with '=='. -
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. -
x
public int x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public int y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-