Browse Source

A working Version 2 of the GameOfLifeAssignment by Marie Trexler

master
Marie Trexler 2 years ago
parent
commit
067aced45b
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      src/Life.java

+ 3
- 0
src/Life.java View File

@@ -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 <gameWorld.length){
for(int i =x-1; i<= x+1;i++){
if(i>=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++;

Loading…
Cancel
Save