This commit is contained in:
tothe 2025-05-06 14:23:42 +02:00
commit be0d7e417f
2 changed files with 21 additions and 6 deletions

View File

@ -106,8 +106,22 @@ public class Board {
}
public String toString() {
//TODO
return "";
PresentState ps = new PresentState();
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));
}
else {
ps.append("--");
}
ps.append(" ");
}
ps.append("\n");
}
return ps.toString("board's present state");
}
public ArrayList<Piece> getPieces() {

View File

@ -6,13 +6,13 @@ public class Move {
private int toX, toY;
private Piece capturedPiece;
public Move ( Piece piece, int fromX, int fromY, int toX, int toY, Piece captured) {
public Move ( Piece piece, int fromX, int fromY, int toX, int toY, Piece capturedPiece){
this.piece = piece;
this.fromX = fromX;
this.fromY = fromY;
this.toX = toX;
this.toY = toY;
this.capturedPiece = capturedPiece;
//this.capturedPiece = capturedPiece;
}
public Piece getPiece() {
return piece;
@ -36,7 +36,8 @@ public class Move {
return capturedPiece != null;
}
public String toString() {
return piece + ":("+ fromX + "," + fromY + ")-("+ toX + "," + toY + ")" + ( capturedPiece != null? "capturing "+ capturedPiece: "");
return piece + ":("+ fromX + "," + fromY + ")-("+ toX + "," + toY + ")" +
( capturedPiece != null? "capturing "+ capturedPiece: "");
}
// remove commit message
/// mjs
}