fix string
This commit is contained in:
parent
f128c00c03
commit
d4de2f66b2
|
|
@ -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<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue