Package student.micro.battleship
Class Position
java.lang.Object
student.micro.battleship.Position
Represents an (x, y) position. Positions are immutable, so the x and
y values can only be set when the position is created.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compare this position object to another to determine if they represent the same (x, y) location.int
getX()
Get the x-coordinate value for this position.int
getY()
Get the y-coordinate value for this position.toString()
Generate a human-readable representation of this position as "(x, y)".
-
Constructor Details
-
Position
public Position(int x, int y) Create a new (x, y) position.- Parameters:
x
- The horizontal x-coordinate value.y
- The vertical y-coordinate value.
-
-
Method Details
-
getX
public int getX()Get the x-coordinate value for this position.- Returns:
- The position's x value.
-
getY
public int getY()Get the y-coordinate value for this position.- Returns:
- The position's y value.
-
equals
Compare this position object to another to determine if they represent the same (x, y) location. -
toString
Generate a human-readable representation of this position as "(x, y)".
-