Guest User

Untitled

a guest
Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. package rules;
  2.  
  3. public class Cell {
  4. protected int numberOfLiveNeighbors;
  5. private CellState state;
  6.  
  7. public Cell() {
  8. this.state = CellState.DEAD;
  9. }
  10.  
  11. public Cell withLiveNeighbors(int numberOfLiveNeighbors) {
  12. this.numberOfLiveNeighbors = numberOfLiveNeighbors;
  13. return this;
  14. }
  15.  
  16. public Cell thatIsAlive() {
  17. this.state = CellState.ALIVE;
  18. return this;
  19. }
  20.  
  21. public boolean isAlive() {
  22. return (state == CellState.ALIVE);
  23. }
  24.  
  25. @Override
  26. public String toString() {
  27. return "I'm " + state + " and I have " + numberOfLiveNeighbors
  28. + " live neighbors.";
  29. }
  30. }
Add Comment
Please, Sign In to add comment