package de.lmu.tcs; /** * Model * * Immutable * * Created by jost on 24.11.15. */ public class Zelle { public final static int TOT=0; public final static int LEBENDIG=1; private final Position position; private final int zustand; public Zelle(Position position, int zustand) { this.position = position; this.zustand = zustand; } public Zelle(Zelle old) { this.position = old.position; this.zustand = old.zustand; } public Position getPosition() { return position; } public boolean istLebendig() { return zustand>=LEBENDIG; } public boolean istTot() { return zustand==TOT; } public Zelle nachkommen() { return this.istTot() ? (new Zelle(this)) : (new Zelle(position, zustand + 1)); } public int alter() { return this.istTot() ? -1 : (this.zustand - 1); } }