added uebung04 task

This commit is contained in:
2025-05-02 14:01:50 +02:00
parent 38a6313e08
commit 192db94f14
8 changed files with 482 additions and 0 deletions

38
uebung04/chess/Piece.java Normal file
View File

@@ -0,0 +1,38 @@
package chess;
public abstract class Piece {
private Color color;
private Board board;
private int row;
private int col;
protected Piece(Color color, Board board, int row, int col) {
if (row < 1 || row > 8 || col < 1 || col > 8)
throw new IllegalArgumentException("Invalid pos " + row + "/" + col);
this.color = color;
this.board = board;
this.row = row;
this.col = col;
board.add(this);
}
public Color getColor() {
return color;
}
public Board getBoard() {
return board;
}
public int getRow() {
return row;
}
public int getCol() {
return col;
}
public abstract char charRep();
public abstract boolean canCapture(Piece other);
}