int min_Y = y - 1; | int min_Y = y - 1; | ||||
int max_Y = y + 1; | int max_Y = y + 1; | ||||
if( min_X < 0) min_X = 0; | |||||
if( max_X >= x_value) max_X = x_value - 1; | |||||
if( min_Y < 0) min_Y = 0; | |||||
if( max_Y >= x_value) max_Y = y_value - 1; | |||||
if( min_X < 0) min_X=0; | |||||
if( max_X >= x_value) max_X=x_value - 1; | |||||
if( min_Y < 0) min_Y=0; | |||||
if( max_Y >= x_value) max_Y=y_value - 1; | |||||
int sum = 0; | int sum = 0; | ||||
for(int dx = min_X; dx <= max_X; dx++){ | for(int dx = min_X; dx <= max_X; dx++){ |
@Test | @Test | ||||
public void keepAliveCell() { | public void keepAliveCell() { | ||||
Life firstGen = new Life(); | Life firstGen = new Life(); | ||||
firstGen.setAlive(1, 1); | |||||
firstGen.setAlive(2, 2); | firstGen.setAlive(2, 2); | ||||
firstGen.setAlive(3, 3); | firstGen.setAlive(3, 3); | ||||
firstGen.setAlive(4, 4); | |||||
ILife nextGen = firstGen.nextGeneration(); | ILife nextGen = firstGen.nextGeneration(); | ||||
assertTrue(nextGen.isAlive(2, 2)); | |||||
assertTrue(nextGen.isAlive(3, 3)); | |||||
} | } | ||||
@Test | @Test |