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



public int countNeighbor(int x, int y) { public int countNeighbor(int x, int y) {
int counter=0; int counter=0;
//counts top row
if(y-1 >=0){ if(y-1 >=0){
for(int i =x-1; i<= x+1;i++){ for(int i =x-1; i<= x+1;i++){
if(i>=0 && i< gameWorld[y-1].length()){ if(i>=0 && i< gameWorld[y-1].length()){
} }
} }
} }
//counts bottom row
if(y+1 <gameWorld.length){ if(y+1 <gameWorld.length){
for(int i =x-1; i<= x+1;i++){ for(int i =x-1; i<= x+1;i++){
if(i>=0 && i< gameWorld[y+1].length()){ if(i>=0 && i< gameWorld[y+1].length()){
} }
} }
} }
//counts sides
if(x-1>=0){ if(x-1>=0){
if(isAlive(x-1,y)){ if(isAlive(x-1,y)){
counter++; counter++;

Loading…
Cancel
Save