diff --git a/src/backend/Rules.java b/src/backend/Rules.java deleted file mode 100644 index 561b4cf..0000000 --- a/src/backend/Rules.java +++ /dev/null @@ -1,64 +0,0 @@ -package backend; -import java.util.ArrayList; - -public class Rules { - - - private int [] survivalRulesArray; - private int[] birthRulesArray; - - - public Rules() { - - //survivalRulesArray = new int[0]; - //birthRulesArray = new int[0]; - } -//initialize my arrays to empty - - - - public void loadRule(ArrayList row) { - String surviveRulesRow = row.get(0); - String[] surviveCells = surviveRulesRow.split(";"); - String birthRulesRow = row.get(1); - String[] birthCells = birthRulesRow.split(";"); - survivalRulesArray = new int[surviveCells.length]; - birthRulesArray = new int[birthCells.length]; - //initialize my arrays with the correct length - - if (row.size() <= 0) { - System.out.println("wrong file buddy, this one's empty"); - - }else if (surviveCells.length<=0) { - System.out.println("wrong file buddy, this one's does not have survival rules, won't work"); - - }else { - for (int x = 0; x < surviveCells.length; x++) { - String eleme = surviveCells[x]; - int value = Integer.parseInt(eleme); - survivalRulesArray[x] = value; - } -//determines the number of alive neighboring cells needed to survive, and places them in the survivalRulesArray - for (int x = 0; x < birthCells.length; x++) { - String elemee = birthCells[x]; - int value = Integer.parseInt(elemee); - birthRulesArray[x] = value; - } -//determines the number of alive neighboring cells needed to birth, and places them in the birthRules list - } - - - - } - - public int[] getBirthRulesArray() { - return this.birthRulesArray; - - } - - public int[] getSurvivalRulesArray() { - return this.survivalRulesArray; - - } - -} diff --git a/src/backend/Simulator.java b/src/backend/Simulator.java index aed4919..f2bda2f 100644 --- a/src/backend/Simulator.java +++ b/src/backend/Simulator.java @@ -146,11 +146,10 @@ public class Simulator extends Thread { // if (world[x][y] == 1) { // newWorld[x][y] = (aliveNeighbors < 2 || aliveNeighbors > 3) ? 0 : 1; // } else { -@ -154,7 +154,7 @@ public class Simulator extends Thread { + - world = newWorld; //world = newWorld; diff --git a/src/backend/World.java b/src/backend/World.java deleted file mode 100644 index 121df0b..0000000 --- a/src/backend/World.java +++ /dev/null @@ -1,76 +0,0 @@ -package backend; - -import java.util.Random; - -public class World { - Simulator simulator; - private int width = simulator.getWidth(); - private int height = simulator.getHeight(); - private int[][] world; - - public World(int width, int height) { - this.width = width; - this.height = height; - world = new int[width][height]; - } - //initializing width and height - - - - public int getWidth() { - return width; - } -//getter for the width - - public int getHeight() { - return height; - } -//getter for the height - - public int[][] getWorld() { - return world; - } -//getter for the world - - - - - public void setWorld(int[][] world, int width, int height) { - this.world = world; - this.width = width; - this.height = height; - printArray (world); - } -//initializes the world - - public void printArray(int[][] array) { - for (int i = 0; i < array.length; i++) { - System.out.print("["); - for (int j = 0; j < array[i].length; j++) { - System.out.print(array[i][j]); - if (j < array[i].length - 1) { - System.out.print(", "); - } - } - System.out.println("]"); - } - } - - - - public int getCell (int x, int y) { - return world[x][y]; - } -//get the value (dead or alive) of my cell at x y - - - - public void setCell(int x, int y, int val) { - world [x][y] = val; - } -//sets the value of a cell at coord x and y to val - - - - -}