You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
784 B

package de.edu.hsfulda.ciip.tdd;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public class GameCell {
private State state;
private State nextState;
private final List<GameCell> neighbors = new ArrayList<>();
public GameCell(State state) {
this.state = state;
}
public State getState() {
return state;
}
public void calculateNextGen() {
List<State> neigborStates = neighbors.stream().map(GameCell::getState).collect(Collectors.toList());
nextState = state.nextBy(neigborStates);
}
public void activateNextGeneration() {
state = nextState;
}
public void addNeigbour(GameCell gameCell) {
neighbors.add(gameCell);
}
}