From b7c1e9b497e8d3c851486bd0075c181d800cf1dc Mon Sep 17 00:00:00 2001 From: lrave Date: Tue, 6 May 2025 14:08:08 +0200 Subject: [PATCH 1/2] comment board --- src/backend/Board.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/Board.java b/src/backend/Board.java index a175569..eedfbb4 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -7,8 +7,8 @@ public class Board { private int selectedX = -1; // negative value means impossible x and y so unselected private int selectedY = -1; - private int turnNumber = 0; // track current turn - private int width; + private int turnNumber = 0; // tracks current turn + private int width; // enables to define the dimensions of board private int height; private Piece[][] board; // 2D array chess board private ArrayList highlightedPositions = new ArrayList<>(); // list of valid positions to highlight @@ -16,7 +16,7 @@ public class Board { public Board(int colNum, int lineNum) { this.width = colNum; this.height = lineNum; - this.board = new Piece[width][height]; // first empty board + this.board = new Piece[width][height]; // first empty board *********REVIEW************ clearConsole(); System.out.println(toString()); // print the chess at the beginning of the game } From 2c410e4eb75cc7643db69ce727856b1b41b652dc Mon Sep 17 00:00:00 2001 From: lrave Date: Tue, 6 May 2025 14:16:22 +0200 Subject: [PATCH 2/2] Additional comment board --- src/backend/Board.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/Board.java b/src/backend/Board.java index eedfbb4..1dd976e 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -29,28 +29,28 @@ public class Board { return height; } - // new piece on the board at x,y + // new piece on the board at x,y (More specifically changes the empty cell of coordinates x,y with a new chess piece) public void setPiece(boolean isWhite, PieceType type, int x, int y) { board[x][y] = new Piece(x, y, type, isWhite); } public boolean isTurnWhite() { - if (turnNumber % 2 == 0) { // even turns including 0 are white's ones + if (turnNumber % 2 == 0) { // even turns including 0 are white's ones (% calculates the reminder of the euclidean division) return true; } else { // same reasoning, odd turns are black's ones return false; } } - public int getTurnNumber() { // these classes change the turn and the increment one solves a problem of infinite loop - return turnNumber; + public int getTurnNumber() { // this class enables to obtain the current turn number while increment adds 1 to this value for each turn + return turnNumber; // Necessarly in two functions to get rid of an infinite loop ****WHY**** } public void incrementTurn() { turnNumber++; } - // set up the chess board taking it as a matrix + // set up the classic chess board taking it as a matrix and putting each corresponding starting piece at its place 0,0 is the top left spot of the board public void populateBoard() { // Black setPiece(false, PieceType.Rook, 0, 0);