From 3cf002e7952adba9b6aa4e31d7095846ce6c9efc Mon Sep 17 00:00:00 2001 From: Romain Murphy Date: Wed, 21 May 2025 18:40:28 +0200 Subject: [PATCH] comments --- OOP_2B1_Project/src/backend/Piece.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/OOP_2B1_Project/src/backend/Piece.java b/OOP_2B1_Project/src/backend/Piece.java index 17979e7..cd34a26 100644 --- a/OOP_2B1_Project/src/backend/Piece.java +++ b/OOP_2B1_Project/src/backend/Piece.java @@ -8,7 +8,7 @@ public abstract class Piece { public PieceType type; public boolean isWhite; - // Track the previous Y position + protected int previousY; private boolean hasMoved = false; @@ -18,7 +18,7 @@ public abstract class Piece { this.y = y; this.type = type; this.isWhite = isWhite; - this.previousY = y; // Initialize previousY to current Y position + this.previousY = y; } public int getX() { @@ -37,17 +37,17 @@ public abstract class Piece { return this.isWhite; } - // Getter for previous Y position + public int getPreviousY() { return previousY; } - // Set the moved flag and update previous Y when the piece moves + public void moveTo(int newX, int newY) { - this.previousY = this.y; // Update previous Y before changing the position + this.previousY = this.y; this.x = newX; this.y = newY; - this.hasMoved = true; // Mark that the piece has moved + this.hasMoved = true; } public boolean hasMoved() { @@ -58,7 +58,7 @@ public abstract class Piece { this.hasMoved = moved; } - // Abstract method to get possible moves (to be implemented by subclasses) + public abstract ArrayList> getPossibleMoves(ArrayList> board); @@ -67,8 +67,8 @@ public abstract class Piece { return "Piece [x=" + x + ", y=" + y + ", type=" + type + ", isWhite=" + isWhite + "]"; } - // This is the overloaded method for getting possible moves with lastMove + public ArrayList> getPossibleMoves(ArrayList> board, Move lastMove) { - return null; // Will be implemented in specific piece subclasses (e.g., Pawn) + return null; } }