clickCell

This commit is contained in:
Balthazar SQUINABOL 2024-04-03 17:42:11 +02:00
parent d05f4211f1
commit b27ef8ffe0
1 changed files with 11 additions and 1 deletions

View File

@ -148,7 +148,17 @@ public class Simulator extends Thread {
* method called when clicking on a cell in the interface * method called when clicking on a cell in the interface
*/ */
public void clickCell(int x, int y) { 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);
} }
/** /**