diff --git a/src/main/java/model/automata/GameOfLifeState.java b/src/main/java/model/automata/GameOfLifeState.java index 12ee370cb07f75700dbf5b688c5a89a627f89515..48f8156020f6d438d39f4a996eafb11727f8ae6a 100644 --- a/src/main/java/model/automata/GameOfLifeState.java +++ b/src/main/java/model/automata/GameOfLifeState.java @@ -14,20 +14,43 @@ public enum GameOfLifeState implements State<GameOfLifeState> { @Override public Color getColor() { - //TODO: à compléter - return Color.BLACK; + switch(this) { + case ALIVE: + return Color.RED; + case DEAD : + return Color.WHITE; + default : return Color.WHITE; + } } @Override public GameOfLifeState next() { - //TODO: à compléter - return null; + switch (this) { + case ALIVE: + return DEAD; + case DEAD: + return ALIVE; + default : return DEAD; + } } @Override public GameOfLifeState update(List<GameOfLifeState> neighbours) { - //TODO: à compléter - return null; + int count = State.count(ALIVE, neighbours); + switch (this) { + case DEAD: + if (count == 3) { + return ALIVE; + } + case ALIVE: + if (count == 3) { + return ALIVE; + } else if (count == 2) { + return ALIVE; + } + default: + return DEAD; + } } - } +