Fix toString method

This commit is contained in:
Noa FOUR 2025-05-06 14:43:38 +02:00
parent d883a7ace7
commit e01db0d8cf
1 changed files with 9 additions and 10 deletions

View File

@ -106,22 +106,21 @@ public class Board {
}
public String toString() {
PresentState ps = new PresentState();
ArrayList<String> ps=new ArrayList<>();
for(int y=0;y<lNum;y++) {
for (int x;x<cNum;x++) {
Piece piece = getPieces(x,y);
if(piece!=null) {
ps.append(piece.isWhite()?"W":"B");
ps.append(piece.getType().toString().charAt(0));
for (int x=0; x<cNum; x++) {
if(selectedCell!=null) {
ps.add(selectedCell.isWhite()?"W":"B");
ps.add(selectedCell.getType().toString());
}
else {
ps.append("--");
ps.add("--");
}
ps.append(" ");
ps.add(" ");
}
ps.append("\n");
ps.add("\n");
}
return ps.toString("board's present state");
return ps.toString();
}
public ArrayList<Piece> getPieces() {