package kata.gameoflife.a20170806; import java.util.Arrays; import java.util.List; /** * Game of Life Kata. * Copyright (c) 2017, Peter Kofler, licensed under BSD License. */ public class LocateNeighbourCells { private final LocateCell locateCenterCell; public LocateNeighbourCells(LocateCell locateCenterCell) { this.locateCenterCell = locateCenterCell; } public List locateNeighbourCells() { return Arrays.asList(// new LocateCell(locateCenterCell.x - 1, locateCenterCell.y - 1), // new LocateCell(locateCenterCell.x - 1, locateCenterCell.y), // new LocateCell(locateCenterCell.x - 1, locateCenterCell.y + 1), // new LocateCell(locateCenterCell.x, locateCenterCell.y - 1), // new LocateCell(locateCenterCell.x, locateCenterCell.y + 1), // new LocateCell(locateCenterCell.x + 1, locateCenterCell.y - 1), // new LocateCell(locateCenterCell.x + 1, locateCenterCell.y), // new LocateCell(locateCenterCell.x + 1, locateCenterCell.y + 1)// ); } // now I split it from locate. OK, but I have to expose x and y, // break encapsulation and expose internals. Sad. }