33 lines
845 B
Java
33 lines
845 B
Java
package backend;
|
|
|
|
public class Move {
|
|
private final int fromX;
|
|
private final int fromY;
|
|
private final int toX;
|
|
private final int toY;
|
|
private Piece capturedPiece;
|
|
|
|
public Move(int fromX, int fromY, int toX, int toY) {
|
|
this.fromX = fromX;
|
|
this.fromY = fromY;
|
|
this.toX = toX;
|
|
this.toY = toY;
|
|
}
|
|
|
|
// Getters
|
|
public int getFromX() { return fromX; }
|
|
public int getFromY() { return fromY; }
|
|
public int getToX() { return toX; }
|
|
public int getToY() { return toY; }
|
|
public Piece getCapturedPiece() { return capturedPiece; }
|
|
|
|
// Setter for captured piece
|
|
public void setCapturedPiece(Piece piece) {
|
|
this.capturedPiece = piece;
|
|
}
|
|
|
|
public String toString() {
|
|
return String.format("Move from (%d,%d) to (%d,%d)", fromX, fromY, toX, toY);
|
|
}
|
|
}
|