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.
|
|
package de.edu.hsfulda.ccip.tdd.withdependencies;
import java.util.Collection; import java.util.LinkedList; import java.util.stream.Collectors;
public class GameOfLifeCell {
private GameOfLifeStatus status; private final Collection<GameOfLifeCell> neighborStates = new LinkedList<>(); private GameOfLifeStatus nexState;
public GameOfLifeCell(GameOfLifeStatus status) { this.status = status; }
public void addNeighbor(GameOfLifeCell neighbor) { neighborStates.add(neighbor); }
public void caclulateNextState() { nexState = status .calculateNextBy(neighborStates.stream().map(GameOfLifeCell::getState).collect(Collectors.toList())); }
public GameOfLifeStatus getState() { return status; }
public void updateState() { status = nexState; }
}
|