Skip to content
Snippets Groups Projects
Commit 810e3415 authored by Guyslain's avatar Guyslain
Browse files

section 6 GameOfLifeState fini

parent 9471d988
No related branches found
No related tags found
No related merge requests found
...@@ -14,20 +14,26 @@ public enum GameOfLifeState implements State<GameOfLifeState> { ...@@ -14,20 +14,26 @@ public enum GameOfLifeState implements State<GameOfLifeState> {
@Override @Override
public Color getColor() { public Color getColor() {
//TODO: à compléter return switch (this) {
return Color.BLACK; case ALIVE -> Color.RED;
case DEAD -> Color.WHITE;
};
} }
@Override @Override
public GameOfLifeState next() { public GameOfLifeState cycle() {
//TODO: à compléter return switch (this) {
return null; case ALIVE -> DEAD;
case DEAD -> ALIVE;
};
} }
@Override @Override
public GameOfLifeState update(List<GameOfLifeState> neighbours) { public GameOfLifeState update(List<GameOfLifeState> neighbours) {
//TODO: à compléter int countAlive = State.count(ALIVE, neighbours);
return null; return (countAlive == 3 || (countAlive == 2 && this == ALIVE))?
ALIVE:
DEAD;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment