package kata.gameoflife.a20170806; import java.util.HashSet; import java.util.Set; /** * Game of Life Kata. * Copyright (c) 2017, Peter Kofler, licensed under BSD License. */ public class LookupLivingCells { private final Set livingCells = new HashSet<>(); public void reproduce(LocateCell locateCell) { livingCells.add(locateCell); } public boolean isAlive(LocateCell locateCell) { return livingCells.contains(locateCell); } @Override public int hashCode() { return 5; } @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } LookupLivingCells that = (LookupLivingCells) o; return this.livingCells.equals(that.livingCells); // TODO only used for assertions in tests } // The collection of locate cells is a first class citizen in OO. // What are the actions it offers? This is a generation, but what // does it do? It adds living cells and looks them up again. }