Steinar Aalstad Lillesund 382960d623 Byttet pakkenavn.
2020-04-14 15:54:09 +02:00

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;
}
}