we added the string toString()

This commit is contained in:
willow.durant 2025-05-06 15:48:40 +02:00
parent 550f987f8b
commit 0890c79bd5
2 changed files with 28 additions and 3 deletions

View File

@ -19,6 +19,7 @@ public class Main {
System.out.println(testBoard.getHeight()); System.out.println(testBoard.getHeight());
System.out.println(testBoard.toString()); System.out.println(testBoard.toString());
//testing the pieces coordinates, colour and type //testing the pieces coordinates, colour and type
Piece testPiece= new Piece(1,2, PieceType.Rook, false); Piece testPiece= new Piece(1,2, PieceType.Rook, false);
System.out.println(testPiece.getX()); System.out.println(testPiece.getX());
@ -28,8 +29,17 @@ public class Main {
//getting the pieces on the board //getting the pieces on the board
System.out.println(testBoard.getPieces()); System.out.println(testBoard.getPieces());
testBoard.setPiece(false, PieceType.Knight, 4, 4);
testBoard.setPiece(false, PieceType.Queen, 3, 3);
//clean the board
// launches graphical interface : // launches graphical interface :
MyInterface mjf = new MyInterface(); MyInterface mjf = new MyInterface();
mjf.setVisible(true); mjf.setVisible(true);

View File

@ -34,7 +34,9 @@ public class Board {
} }
public void setPiece(boolean isWhite, PieceType type, int x, int y) { public void setPiece(boolean isWhite, PieceType type, int x, int y) {
//TODO board[y][x]= new Piece (x, y, type, isWhite);
} }
public void populateBoard() { public void populateBoard() {
@ -56,11 +58,24 @@ public class Board {
public void cleanBoard() { public void cleanBoard() {
//TODO for(int y=0; y<8; y++) {
for(int x=0; x<8; x++) {
board[x][y]= null;
}
}
} }
public String toString() { public String toString() {
//TODO
for (int y=0; y< height; y++) {
for (int x=0; x<width; x++) {
}
}
return ""; return "";
} }