Exercises/chess/pieces/Piece.java

51 lines
1.2 KiB
Java
Raw Normal View History

2025-03-01 16:06:01 +01:00
package de.vivi.chess.pieces;
import de.vivi.chess.board.Board;
import de.vivi.chess.board.Field;
public abstract class Piece {
private final Color color;
private final Type type;
protected char symbol;
protected Piece(Color color, Type type) {
this.color = color;
this.type = type;
symbol = '\u0000';
}
/**
* TODO: implement
* <p>
* This method needs to be implemented in each piece by
* using inheritance. It returns true if the move from the
* from field to the to field is considered a valid move
* for the type of piece this method is called on. Otherwise
* it returns false.
*/
public abstract boolean isValidMove(Board board, Field from, Field to);
public Color getColor() {
// TODO: implement
return color;
}
public Type getType() {
// TODO: implement
return type;
}
/**
* TODO: implement
* <p>
* Use unicode symbols for the chess pieces. You can find
* them here:
* <a href="https://en.wikipedia.org/wiki/Chess_symbols_in_Unicode">Unicode chess pieces</a>
*/
public char getSymbol() {
return symbol;
}
}