Saving progress for toString, does not work

This commit is contained in:
hugomanipoud2 2025-05-14 16:31:02 +02:00
parent 164481ca87
commit e44c7ad881
1 changed files with 18 additions and 3 deletions

View File

@ -6,12 +6,15 @@ public class Board {
private int column;
private int line;
private ArrayList<Piece> pieces;
private ArrayList<String> boardState;
//initiation of the board, creating an 8 * 8 grid
public Board(int colNum, int lineNum) {
this.column = colNum;
this.line = lineNum;
this.pieces = new ArrayList<>();
this.boardState = new ArrayList<>();
}
public int getWidth() {
@ -72,9 +75,21 @@ public class Board {
pieces.clear();
}
public String toString() {
//TODO
return "";
public String toString(ArrayList<Piece> pieces) {
String[] boardStateStr = "";
for(Piece piece : pieces) {
Boolean colorofpiece = piece.isWhite();
if(colorofpiece == true) {
boardState.add("White");
}
else {
boardState.add("Black");
}
}
return boardStateStr;
}
public ArrayList<Piece> getPieces() {