Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rules;
- public class Cell {
- protected int numberOfLiveNeighbors;
- private CellState state;
- public Cell() {
- this.state = CellState.DEAD;
- }
- public Cell withLiveNeighbors(int numberOfLiveNeighbors) {
- this.numberOfLiveNeighbors = numberOfLiveNeighbors;
- return this;
- }
- public Cell thatIsAlive() {
- this.state = CellState.ALIVE;
- return this;
- }
- public boolean isAlive() {
- return (state == CellState.ALIVE);
- }
- @Override
- public String toString() {
- return "I'm " + state + " and I have " + numberOfLiveNeighbors
- + " live neighbors.";
- }
- }
Add Comment
Please, Sign In to add comment