toString final

This commit is contained in:
Admin 2025-05-06 14:49:48 +02:00
parent fbce3ce878
commit 7a0fad8514
1 changed files with 19 additions and 2 deletions

View File

@ -92,8 +92,25 @@ public class Board {
}
public String toString() {
//TODO
return "";
String result = "";
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
String c = ".";
for (Piece p : pieces) {
if (p.getX() == x && p.getY() == y) {
String letter = p.getType().getSummary();
if (p.isWhite()) {
c = "W" + letter;
} else {
c = "B" + letter;
}
}
}
result += c + " ";
}
result += "\n";
}
return result;
}
public ArrayList<Piece> getPieces() {