summaryrefslogtreecommitdiff
path: root/ws2015/eip/blaetter/07/H7-1B/de/lmu/tcs/Zelle.java
blob: a7c6ad6999bd6c2a838d9bd9d348ef7b29b65e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
    }
}