Android Open Source - GoL Cell






From Project

Back to project page GoL.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project GoL listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package hlfernandez.sing.ei.uvigo.es.gameoflife;
/*from  w w  w.j  a  va 2  s.c o  m*/
import java.util.Arrays;
import java.util.List;

public class Cell {

    private int x;
    private int y;

    public Cell(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return this.x;
    }

    public int getY() {
        return this.y;
    }

    public List<Cell> getNeighbourds() {
        return Arrays.asList(new Cell[] {
                new Cell(x - 1, y - 1),  new Cell(x - 1, y), new Cell(x - 1, y + 1),
                new Cell(x, y - 1),             new Cell(x, y + 1),
                new Cell(x + 1, y - 1),  new Cell(x + 1, y),  new Cell(x + 1, y + 1) });
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + x;
        result = prime * result + y;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Cell other = (Cell) obj;
        if (x != other.x)
            return false;
        if (y != other.y)
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "x = " + this.getX() + ", y = " + this.getY();
    }
}




Java Source Code List

hlfernandez.sing.ei.uvigo.es.gameoflife.ApplicationTest.java
hlfernandez.sing.ei.uvigo.es.gameoflife.BoardAdapter.java
hlfernandez.sing.ei.uvigo.es.gameoflife.Board.java
hlfernandez.sing.ei.uvigo.es.gameoflife.Cell.java
hlfernandez.sing.ei.uvigo.es.gameoflife.MainActivity.java
hlfernandez.sing.ei.uvigo.es.gameoflife.SettingsActivity.java
hlfernandez.sing.ei.uvigo.es.gameoflife.SettingsFragment.java