The tests directly create a ChessPiece in TestUtilities.java. This makes it impossible for a student to implement inheritance as a solution for implementing the different chess pieces.
public static ChessBoard loadBoard(String boardText) {
var board = new ChessBoard();
for (var c : boardText.toCharArray()) {
switch (c) {
// ...
default -> {
ChessGame.TeamColor color = Character.isLowerCase(c) ? ChessGame.TeamColor.BLACK : ChessGame.TeamColor.WHITE;
var type = CHAR_TO_TYPE_MAP.get(Character.toLowerCase(c));
var position = new ChessPosition(row, column);
var piece = new ChessPiece(color, type);
board.addPiece(position, piece);
column++;
}
}
}
```
Instead we could create a factory method on ChessPiece that `loadBoard` would call.
We went away from the factory pattern a couple years ago. I'm not sure why that was and so we might run into a problem if we partially move back to it.
The tests directly create a ChessPiece in
TestUtilities.java. This makes it impossible for a student to implement inheritance as a solution for implementing the different chess pieces.