mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-08 11:09:35 +01:00
54 lines
1.3 KiB
Java
54 lines
1.3 KiB
Java
package inf112.fiasko.roborally.elementproperties;
|
|
|
|
/**
|
|
* This class represent a position on the board
|
|
*/
|
|
public class Position {
|
|
|
|
private final int xCoordinate;
|
|
private final int yCoordinate;
|
|
|
|
/**
|
|
* Initializes the position
|
|
* @param xCoordinate The x coordinate of the position
|
|
* @param yCoordinate The y coordinate of the position
|
|
*/
|
|
public Position(int xCoordinate, int yCoordinate) {
|
|
this.xCoordinate = xCoordinate;
|
|
this.yCoordinate = yCoordinate;
|
|
}
|
|
|
|
/**
|
|
* Gets the x coordinate of the position
|
|
* @return The x coordinate of the position
|
|
*/
|
|
public int getXCoordinate() {
|
|
return xCoordinate;
|
|
}
|
|
|
|
/**
|
|
* Gets the y coordinate of the position
|
|
* @return The y coordinate of the position
|
|
*/
|
|
public int getYCoordinate() {
|
|
return yCoordinate;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("X: %d, Y: %d", xCoordinate, yCoordinate);
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (obj.getClass() != Position.class) {
|
|
return false;
|
|
}
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
return this.xCoordinate == ((Position) obj).xCoordinate &&
|
|
this.yCoordinate == ((Position) obj).yCoordinate;
|
|
}
|
|
}
|