Skip to content
Snippets Groups Projects
Commit 7300b8cb authored by POUSSARDIN Malo's avatar POUSSARDIN Malo
Browse files

TP7 étape 2

parent 538d361d
Branches main
No related tags found
No related merge requests found
Pipeline #40522 failed
......@@ -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
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment