From 067aced45bc5bc4e851d763b58d974cee1ca902c Mon Sep 17 00:00:00 2001 From: Marie Date: Thu, 23 Dec 2021 09:40:41 +0100 Subject: [PATCH] A working Version 2 of the GameOfLifeAssignment by Marie Trexler --- src/Life.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Life.java b/src/Life.java index 07d2e59..022ce09 100644 --- a/src/Life.java +++ b/src/Life.java @@ -107,6 +107,7 @@ public class Life implements ILife { public int countNeighbor(int x, int y) { int counter=0; + //counts top row if(y-1 >=0){ for(int i =x-1; i<= x+1;i++){ if(i>=0 && i< gameWorld[y-1].length()){ @@ -116,6 +117,7 @@ public class Life implements ILife { } } } + //counts bottom row if(y+1 =0 && i< gameWorld[y+1].length()){ @@ -125,6 +127,7 @@ public class Life implements ILife { } } } + //counts sides if(x-1>=0){ if(isAlive(x-1,y)){ counter++;