Newer
Older
import java.util.List;
/**
* {@link GameOfLifeState} instances represent the possible states of a {@link GameOfLifeState}.
*/
public enum GameOfLifeState implements State<GameOfLifeState> {
case ALIVE:
return Color.RED;
case DEAD:
return Color.WHITE;
default:
/* correction avec if :
if this.equals(ALIVE) {
return COLOR.RED;
else {
return COLOR.WHITE;
*/
switch (this) {
case ALIVE:
return DEAD;
case DEAD:
return ALIVE;
/* correction avec if :
if this.equals(ALIVE) {
return DEAD;
else {
return ALIVE;
*/
public GameOfLifeState update(List<GameOfLifeState> neighbours) {
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;
}