@Test public void testApplyRules() { System.out.println("applyRules"); Set< Cell > liveCells = new HashSet<Cell>(); liveCells.add(new Cell(1,1,State.DEAD)); liveCells.add(new Cell(1,3,State.LIVE)); liveCells.add(new Cell(2,3,State.DEAD)); liveCells.add(new Cell(3,1,State.LIVE)); liveCells.add(new Cell(3,2,State.LIVE)); liveCells.add(new Cell(2,1,State.DEAD)); RuleRunner instance=new RuleRunner(); Set<Cell> expResult = new HashSet<Cell>(); expResult.add(new Cell(1,1,State.LIVE)); expResult.add(new Cell(3,2,State.LIVE)); Set<Cell> result = instance.applyRules(liveCells); assertEquals(expResult, result); }
public Set<Cell> applyRules(Set<Cell> liveCells) { HashSet<Cell> nextGeneration=new HashSet<Cell>(); Set<Cell> neighbouringCells; for(Cell cellFromCurrentGeneration: liveCells) { processCell(cellFromCurrentGeneration,liveCells,nextGeneration); neighbouringCells=gameStratedy.findNeighbours(cellFromCurrentGeneration, liveCells); for(Cell neighbouringCell:neighbouringCells) { processCell(neighbouringCell,liveCells,nextGeneration); } } return filterDead(nextGeneration); }
RuleRunner { public Set<Cell> applyRules(Set<Cell> liveCells) { HashSet<Cell> nextGeneration=new HashSet<Cell>(); Set<Cell> neighbouringCells; for(Cell cellFromCurrentGeneration: liveCells) { processCell(cellFromCurrentGeneration,liveCells,nextGeneration); neighbouringCells=gameStratedy.findNeighbours(cellFromCurrentGeneration, liveCells); for(Cell neighbouringCell:neighbouringCells) { processCell(neighbouringCell,liveCells,nextGeneration); } } return filterDead(nextGeneration); } }
RuleRunner { public Set<Cell> applyRules(Set<Cell> liveCells) { HashSet<Cell> nextGeneration=new HashSet<Cell>(); Set<Cell> neighbouringCells; for(Cell cellFromCurrentGeneration: liveCells) { processCell(cellFromCurrentGeneration,liveCells,nextGeneration); neighbouringCells=gameStratedy.findNeighbours(cellFromCurrentGeneration, liveCells); for(Cell neighbouringCell:neighbouringCells) { processCell(neighbouringCell,liveCells,nextGeneration); } } return filterDead(nextGeneration); } RuleRunner(GameStratedy gameStratedy); }
RuleRunner { public Set<Cell> applyRules(Set<Cell> liveCells) { HashSet<Cell> nextGeneration=new HashSet<Cell>(); Set<Cell> neighbouringCells; for(Cell cellFromCurrentGeneration: liveCells) { processCell(cellFromCurrentGeneration,liveCells,nextGeneration); neighbouringCells=gameStratedy.findNeighbours(cellFromCurrentGeneration, liveCells); for(Cell neighbouringCell:neighbouringCells) { processCell(neighbouringCell,liveCells,nextGeneration); } } return filterDead(nextGeneration); } RuleRunner(GameStratedy gameStratedy); Set<Cell> applyRules(Set<Cell> liveCells); }
RuleRunner { public Set<Cell> applyRules(Set<Cell> liveCells) { HashSet<Cell> nextGeneration=new HashSet<Cell>(); Set<Cell> neighbouringCells; for(Cell cellFromCurrentGeneration: liveCells) { processCell(cellFromCurrentGeneration,liveCells,nextGeneration); neighbouringCells=gameStratedy.findNeighbours(cellFromCurrentGeneration, liveCells); for(Cell neighbouringCell:neighbouringCells) { processCell(neighbouringCell,liveCells,nextGeneration); } } return filterDead(nextGeneration); } RuleRunner(GameStratedy gameStratedy); Set<Cell> applyRules(Set<Cell> liveCells);  }