package edu.wright.hendrix11.conway.logic;

/**
 * @author Joe Hendrix
 */
public class Cell {
    private boolean alive = false;
    private Cell northernCell;
    private Cell southernCell;
    private Cell easternCell;
    private Cell westernCell;

    public Cell() {
    }

    public Cell(boolean alive) {
        this.alive = alive;
    }

    public void setEasternCell(Cell easternCell) {
        easternCell.westernCell = this;
        this.easternCell = easternCell;
    }

    public void setNorthernCell(Cell northernCell) {
        northernCell.southernCell = this;
        this.northernCell = northernCell;
    }

    public void setSouthernCell(Cell southernCell) {
        southernCell.northernCell = this;
        this.southernCell = southernCell;
    }

    public void setWesternCell(Cell westernCell) {
        westernCell.easternCell = this;
        this.westernCell = westernCell;
    }

    public Cell getEasternCell() {
        return easternCell;
    }

    public Cell getNorthernCell() {
        return northernCell;
    }

    public Cell getSouthernCell() {
        return southernCell;
    }

    public Cell getWesternCell() {
        return westernCell;
    }

    public void toggle() {
        alive = !alive;
    }

    public boolean isAlive() {
        return alive;
    }

    public int getNumberLivingNeighbors() {
        int count = 0;

        if(northernCell != null && northernCell.isAlive()) {
            count++;
        }

        if(southernCell != null && southernCell.isAlive()) {
            count++;
        }

        if(easternCell != null && easternCell.isAlive()) {
            count++;
        }

        if(westernCell != null && westernCell.isAlive()) {
            count++;
        }

        return count;
    }

    @Override
    public int hashCode() {
        return alive ? 1 : 0;
    }

    @Override
    public boolean equals(Object o) {
        return this == o;
    }
}

@@ -1373,16 +1373,2102 @@
 unt = 0;
+%0A        %0A        count += countCardinalLivingNeighbors();%0A        count += countDiagonalLivingNeighbors();%0A        %0A        return count;%0A    %7D%0A    %0A    private int countNorthernDiagonalLivingNeighbors() %7B%0A        int count = 0;%0A        %0A        if(northernCell != null) %7B%0A            %0A            if(northernCell.easternCell != null && northernCell.easternCell.isAlive()) %7B%0A                count++;%0A            %7D%0A            %0A            if(northernCell.westernCell != null && northernCell.westernCell.isAlive()) %7B%0A                count++;%0A            %7D%0A            %0A        %7D else %7B%0A            %0A            if(easternCell != null && easternCell.northernCell != null && easternCell.northernCell.isAlive()) %7B%0A                count++;%0A            %7D%0A            %0A            if(westernCell != null && westernCell.northernCell != null && westernCell.northernCell.isAlive()) %7B%0A                count++;%0A            %7D%0A        %7D%0A        %0A        return count;%0A    %7D%0A    %0A    private int countSouthernDiagonalLivingNeighbors() %7B%0A        int count = 0;%0A        %0A        if(southernCell != null) %7B%0A            %0A            if(southernCell.easternCell != null && southernCell.easternCell.isAlive()) %7B%0A                count++;%0A            %7D%0A            %0A            if(southernCell.westernCell != null && southernCell.westernCell.isAlive()) %7B%0A                count++;%0A            %7D%0A            %0A        %7D else %7B%0A            %0A            if(easternCell != null && easternCell.southernCell != null && easternCell.southernCell.isAlive()) %7B%0A                count++;%0A            %7D%0A            %0A            if(westernCell != null && westernCell.southernCell != null && westernCell.southernCell.isAlive()) %7B%0A                count++;%0A            %7D%0A        %7D%0A        %0A        return count;%0A    %7D%0A    %0A    private int countDiagonalLivingNeighbors() %7B%0A        int count = 0;%0A        %0A        count += countNorthernDiagonalLivingNeighbors;%0A        count += countSouthernDiagonalLivingNeighbors;%0A        %0A        return count;%0A    %7D%0A    %0A    private int countCardinalLivingNeighbors() %7B%0A        int count = 0;
 %0A%0A      

Update Cell.java