Compare commits

...

4 Commits

Author SHA1 Message Date
mathy adb389ddc1 Merge branch 'master' of
https://gitarero.ecam.fr/mathys.balme/OOP_1B6_Project.git
2025-05-06 15:00:42 +02:00
mathy b2a57c85ec Merge branch 'master' of https://gitarero.ecam.fr/mathys.balme/OOP_1B6_Project.git 2025-05-06 15:00:16 +02:00
mathy 8fd68523ef remove switch 2025-05-06 14:59:48 +02:00
mathy ea4a1714d0 switched removed 2025-05-06 14:44:40 +02:00
1 changed files with 2 additions and 12 deletions

View File

@ -111,21 +111,11 @@ public class Board {
} else {
// convert each piece of both color into a character
Piece piece = board[x][y];
char pieceChar;
switch (piece.getType()) { // switch function avoids too many if-else
case King: pieceChar = 'K'; break;
case Queen: pieceChar = 'Q'; break;
case Bishop: pieceChar = 'B'; break;
case Knight: pieceChar = 'N'; break; // N because we already have King
case Rook: pieceChar = 'R'; break;
case Pawn: pieceChar = 'P'; break;
default: pieceChar = '?'; break; // safety net
}
String pieceChar = piece.getType().getSummary();
// Make black pieces in lowercase
if (!piece.isWhite()) {
pieceChar = Character.toLowerCase(pieceChar);
pieceChar = pieceChar.toLowerCase();
}
str.append(pieceChar).append(" "); // gives structure to the output