fix string

This commit is contained in:
MSI 2025-05-06 16:14:04 +02:00
parent f128c00c03
commit d4de2f66b2
1 changed files with 14 additions and 15 deletions

View File

@ -106,22 +106,21 @@ public class Board {
}
public String toString() {
ArrayList<String> ps=new ArrayList<>();
for(int y=0;y<lNum;y++) {
for (int x=0; x<cNum; x++) {
if (selectedCell != null) {
ps.add(selectedCell.isWhite() ? "W" : "B");
ps.add(selectedCell.getType().toString());
}
else {
ps.add("--");
}
ps.add(" ");
}
ps.add("\n");
}
return ps.toString();
StringBuilder sb = new StringBuilder();
for (int y = 0; y < lNum; y++) {
for (int x = 0; x < cNum; x++) {
Piece p = cells[x][y];
if (p != null) {
sb.append(p.isWhite() ? "W" : "B").append(p.getType().toString().charAt(0)).append(" ");
} else {
sb.append("-- ");
}
}
sb.append("\n");
}
return sb.toString();
}
public ArrayList<Piece> getPieces() {
ArrayList<Piece> pieces = new ArrayList<>();