From a5e35fdf310bc6a0cf4d9c9af8fbbdaba4f3a7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=C3=A9o?= Date: Tue, 7 May 2024 17:26:16 +0200 Subject: [PATCH] did isLoopingBorder and toggleLoopingBorder, started gridCreation but gotta finish --- src/backend/Simulator.java | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index 5b3f98e..18103fb 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -1,6 +1,8 @@ package backend; import java.util.ArrayList; +import managementImage.ImageColor; +import students.Gradient; import windowInterface.MyInterface; public class Simulator extends Thread { @@ -24,6 +26,7 @@ public class Simulator extends Thread { private boolean loopingBorder; private boolean clickActionFlag; private int loopDelay = 150; + private int[][] grid; //TODO : add missing attribute(s) @@ -37,10 +40,10 @@ public class Simulator extends Thread { agents = new ArrayList(); fieldBirthValues = new ArrayList(); fieldSurviveValues = new ArrayList(); - + cellState = false; //TODO : add missing attribute initialization - + grid = gridCreation(); //Default rule : Survive always, birth never for(int i =0; i<9; i++) { @@ -48,6 +51,18 @@ public class Simulator extends Thread { } } + public int[][] gridCreation() { + int[][] newGrid = new int[COL_NUM][LINE_NUM]; + for (int x = 0; x < COL_NUM; x ++) { + for (int y = 0; y < LINE_NUM; y ++) { + //TODO set cell values + + } + } + return newGrid; + } + + public int getWidth() { return COL_NUM; @@ -151,7 +166,7 @@ public class Simulator extends Thread { * @return value of cell */ public int getCell(int x, int y) { - //TODO : complete method with proper return + //get the value (dead or alive) of my cell at x y return 0; } /** @@ -250,13 +265,15 @@ public class Simulator extends Thread { } public boolean isLoopingBorder() { - //TODO : complete method with proper return - return false; - } + return loopingBorder; + } public void toggleLoopingBorder() { - //TODO : complete method - + if (loopingBorder){ + loopingBorder = false; + }else { + loopingBorder = true; + } } public void setLoopDelay(int delay) {