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> { ...@@ -44,7 +44,12 @@ public interface State<S> {
* @return The number of times the specified state appears in the list of neighbors. * @return The number of times the specified state appears in the list of neighbors.
*/ */
static <T> int count(T state, List<T> neighbours) { static <T> int count(T state, List<T> neighbours) {
//TODO: à compléter int count = 0;
return 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> { ...@@ -14,14 +14,19 @@ public enum GameOfLifeState implements State<GameOfLifeState> {
@Override @Override
public Color getColor() { public Color getColor() {
//TODO: à compléter return this == ALIVE ? Color.RED : Color.WHITE;
return Color.BLACK;
} }
@Override @Override
public GameOfLifeState next() { public GameOfLifeState next() {
//TODO: à compléter switch (this) {
return null; case ALIVE:
return DEAD;
case DEAD:
return ALIVE;
default:
return ALIVE;
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment