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
-
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.boolean
Indicates whether some other object is "equal to" this one.int
hashCode()
Returns a hash code value for this object.boolean
isValid()
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 String
toString()
Returns a string representation of this record class.int
x()
Returns the value of thex
record component.int
y()
Returns the value of they
record component.
-
Constructor Details
-
Point
public Point(int x, int y) Creates an instance of aPoint
record class.- Parameters:
x
- the value for thex
record componenty
- the value for they
record 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 thex
record component.- Returns:
- the value of the
x
record component
-
y
public int y()Returns the value of they
record component.- Returns:
- the value of the
y
record component
-