2020-04-14 15:54:09 +02:00
|
|
|
package inf112.fiasko.roborally.elementproperties;
|
2020-02-18 14:39:33 +01:00
|
|
|
|
2020-02-18 16:53:57 +01:00
|
|
|
/**
|
|
|
|
* This class represent a position on the board
|
|
|
|
*/
|
2020-02-18 14:39:33 +01:00
|
|
|
public class Position {
|
|
|
|
|
2020-02-20 14:10:56 +01:00
|
|
|
private final int xCoordinate;
|
|
|
|
private final int yCoordinate;
|
2020-02-18 14:39:33 +01:00
|
|
|
|
|
|
|
/**
|
2020-02-18 16:53:57 +01:00
|
|
|
* Initializes the position
|
|
|
|
* @param xCoordinate The x coordinate of the position
|
|
|
|
* @param yCoordinate The y coordinate of the position
|
2020-02-18 14:39:33 +01:00
|
|
|
*/
|
2020-02-18 16:53:57 +01:00
|
|
|
public Position(int xCoordinate, int yCoordinate) {
|
|
|
|
this.xCoordinate = xCoordinate;
|
|
|
|
this.yCoordinate = yCoordinate;
|
2020-02-18 14:39:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-02-18 16:53:57 +01:00
|
|
|
* Gets the x coordinate of the position
|
|
|
|
* @return The x coordinate of the position
|
2020-02-18 14:39:33 +01:00
|
|
|
*/
|
|
|
|
public int getXCoordinate() {
|
2020-02-18 16:53:57 +01:00
|
|
|
return xCoordinate;
|
2020-02-18 14:39:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-02-18 16:53:57 +01:00
|
|
|
* Gets the y coordinate of the position
|
|
|
|
* @return The y coordinate of the position
|
2020-02-18 14:39:33 +01:00
|
|
|
*/
|
|
|
|
public int getYCoordinate() {
|
2020-02-18 16:53:57 +01:00
|
|
|
return yCoordinate;
|
2020-02-18 14:39:33 +01:00
|
|
|
}
|
2020-02-22 23:12:17 +01:00
|
|
|
|
2020-02-27 10:38:26 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return String.format("X: %d, Y: %d", xCoordinate, yCoordinate);
|
|
|
|
}
|
|
|
|
|
2020-02-22 23:12:17 +01:00
|
|
|
@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;
|
|
|
|
}
|
2020-02-18 14:39:33 +01:00
|
|
|
}
|