diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index a1dbae7..b9425fe 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -213,8 +213,20 @@ public class Simulator extends Thread { * the simulated world in its present state */ public ArrayList getSaveState() { - //TODO : complete method with proper return - return null; + ArrayList saveState = new ArrayList<>(); + + for (int y = 0; y < LINE_NUM; y++) { + StringBuilder line = new StringBuilder(); + for (int x = 0; x < COL_NUM; x++) { + line.append(grid[x][y]); + if (x < COL_NUM - 1) { + line.append(";"); + } + } + saveState.add(line.toString()); + } + + return saveState; } /** * @@ -294,9 +306,12 @@ public class Simulator extends Thread { * @see loadRule for inverse process */ public ArrayList getRule() { - //TODO : complete method with proper return - - return null; + ArrayList rules = new ArrayList<>(); + rules.add("1"); // Rule 1: Any live cell with fewer than two live neighbours dies + rules.add("2;3"); // Rule 2: Any live cell with two or three live neighbours will live + rules.add("4"); // Rule 3: Any live cell with more than three live neighbours dies + rules.add("3"); // Rule 4: Any dead cell with exactly three live neighbours becomes alive + return rules; } public void loadRule(ArrayList lines) {