From b27ef8ffe0dc2c5208185be606be88557d309e4e Mon Sep 17 00:00:00 2001 From: "balthazar.squinabol" Date: Wed, 3 Apr 2024 17:42:11 +0200 Subject: [PATCH] clickCell --- src/backend/Simulator.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 9cb9b44..3698e30 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -148,7 +148,17 @@ public class Simulator extends Thread { * method called when clicking on a cell in the interface */ public void clickCell(int x, int y) { - //TODO : complete method + int currentCellValue = getCell(x, y); + int newCellValue; + if (currentCellValue == 0) { + System.out.println("Cell :" + x + "," + y + " is now alive"); + newCellValue = 1; // If the cell is dead, make it alive + } else { + System.out.println("Cell :" + x + "," + y + " is now dead"); + newCellValue = 0; // If the cell is alive, make it dead + } + + setCell(x, y, newCellValue); } /**