From 7fe7f6c17ec02ccd959084ab7ec74b6e80fcb057 Mon Sep 17 00:00:00 2001 From: hugomanipoud2 Date: Fri, 23 May 2025 10:50:59 +0200 Subject: [PATCH] trying to implement undolastmove with hashmaps, they work like dictionnaries in python, the key will be turnNb and the associated value will be the arraylist associated --- OOP_3B5_Project/src/backend/Board.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OOP_3B5_Project/src/backend/Board.java b/OOP_3B5_Project/src/backend/Board.java index 8cd21a7..9ce9c2b 100644 --- a/OOP_3B5_Project/src/backend/Board.java +++ b/OOP_3B5_Project/src/backend/Board.java @@ -1,6 +1,7 @@ package backend; import java.util.ArrayList; +import java.util.HashMap; // for unddolastmove public class Board { private int column; // constructors for column and line @@ -11,7 +12,7 @@ public class Board { private int selectX = -1; private int selectY = -1; private Move move; - private int zero = -1; + private HashMap> boardHistory; // hashmap for undolastmove //initiation of the board, creating an 8 * 8 grid public Board(int colNum, int lineNum) { @@ -19,6 +20,7 @@ public class Board { this.line = lineNum; this.pieces = new ArrayList<>(); this.move = new Move(pieces, this); //adding an acces to Move methods and linkking the arraylist to the class methods + this.boardHistory = new HashMap<>(); //for history of the board an make undolastmove possible, acts like a dictionnary in python } @@ -37,10 +39,6 @@ public class Board { public void setTurnNb(int turnNb) { this.turnNb = turnNb; } - - public int getZero() { - return this.zero; - } public boolean isTurnWhite() { if (turnNb % 2 == 0){