A working Version 2 of the GameOfLifeAssignment by Marie Trexler
This commit is contained in:
parent
7c967ddab4
commit
067aced45b
@ -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…
x
Reference in New Issue
Block a user