adding forgotten testing by using examples

This commit is contained in:
Marleen PETERSON 2025-05-17 19:34:45 +02:00
parent f90db6b70c
commit 561c2a00a6
1 changed files with 37 additions and 13 deletions

View File

@ -1,19 +1,43 @@
import backend.Board;
import backend.CheckKing;
import backend.Piece;
import backend.PieceType;
import windowInterface.MyInterface;
public class Main {
public static void main(String[] args) {
//basic board initialization
Board board = new Board(8, 8);
board.populateBoard();
System.out.println("Initial board:");
System.out.println(board.toString());
public static void main(String[] args) {
// testing :
Board testBoard = new Board(8, 8);
testBoard.populateBoard();
System.out.println(testBoard.toString());
System.out.println(testBoard.getWidth() + "*" + testBoard.getHeight());
//test critical game functions (quick verification)
System.out.println("\nTesting core functionality:");
// launches graphical interface :
MyInterface mjf = new MyInterface();
mjf.setVisible(true);
}
//test piece movement
System.out.println("White pawn at (4,6) moves:");
Piece pawn = board.getBoardMatrix()[6][4];
System.out.println(board.getValidMoves(pawn, true));
//test turn management
System.out.println("\nCurrent turn: " + (board.isTurnWhite() ? "White" : "Black"));
//test save/load functionality
String[] savedGame = board.toFileRep();
System.out.println("\nSaved game turn: " + savedGame[8]);
//test move execution
System.out.println("\nMaking a sample move (e2-e4):");
board.userTouch(4, 6); // Select pawn
board.userTouch(4, 4); // Move pawn
System.out.println("Board after move:");
System.out.println(board.toString());
//test undo functionality
System.out.println("\nUndoing last move:");
board.undoLastMove();
System.out.println("Board after undo:");
System.out.println(board.toString());
}
}