diff --git a/OOP_D7_Project/src/backend/World.java b/OOP_D7_Project/src/backend/World.java index f04cffd..fb838d0 100644 --- a/OOP_D7_Project/src/backend/World.java +++ b/OOP_D7_Project/src/backend/World.java @@ -17,7 +17,7 @@ public class World { this.teleportX = new Teleporter(width); this.teleportY = new Teleporter(height); } - //method to + //method to create a random field public void randomizer(double randValue) { for (int i =0; i < currentWorld.length; i++) { for (int j =0; j < currentWorld[i].length; j++) { @@ -32,15 +32,19 @@ public class World { } } + // Method to get the value of a cell in the grid public int getValue(int x, int y) { + // Check if the position is inside the Grid if (x == -99 || y == -99 ) { return 0; } return currentWorld [x][y]; } + // Method to set the value of a cell in the grid public void setValue(int x, int y, int value) { currentWorld [x][y] = value; } + //Method to count the number of living cells around a cell public int getLiving(int x,int y,int radius,boolean loop) { int out = 0; for (int i=x-radius;i<=x+radius;i++) {