diff --git a/src/main/java/model/State.java b/src/main/java/model/State.java index 1954558460d6969d09544c64c40152d97c1a736e..3ac29c03cc08f33e90ef098b04e8e52b5678d6af 100644 --- a/src/main/java/model/State.java +++ b/src/main/java/model/State.java @@ -44,7 +44,12 @@ public interface State<S> { * @return The number of times the specified state appears in the list of neighbors. */ static <T> int count(T state, List<T> neighbours) { - //TODO: à compléter - return 0; + int count = 0; + for (T neighbour : neighbours) { + if (state.equals(neighbour)) { + count++; + } + } + return count; } } \ No newline at end of file diff --git a/src/main/java/model/automata/GameOfLifeState.java b/src/main/java/model/automata/GameOfLifeState.java index 12ee370cb07f75700dbf5b688c5a89a627f89515..7f8cb8bafb9ed46b9469d90ce5a997588c1c72e0 100644 --- a/src/main/java/model/automata/GameOfLifeState.java +++ b/src/main/java/model/automata/GameOfLifeState.java @@ -14,14 +14,19 @@ public enum GameOfLifeState implements State<GameOfLifeState> { @Override public Color getColor() { - //TODO: à compléter - return Color.BLACK; + return this == ALIVE ? Color.RED : Color.WHITE; } @Override public GameOfLifeState next() { - //TODO: à compléter - return null; + switch (this) { + case ALIVE: + return DEAD; + case DEAD: + return ALIVE; + default: + return ALIVE; + } } @Override