LifeTest third step passed
This commit is contained in:
parent
2b8a04fe31
commit
c620449f0f
Binary file not shown.
Binary file not shown.
@ -92,7 +92,7 @@ public class Life implements ILife {
|
|||||||
else if(isAlive(x,y) && alive < 2){
|
else if(isAlive(x,y) && alive < 2){
|
||||||
nextBoard[y] = nextBoard[y].substring(0, x) + ' ' + nextBoard[y].substring(x+1);
|
nextBoard[y] = nextBoard[y].substring(0, x) + ' ' + nextBoard[y].substring(x+1);
|
||||||
}
|
}
|
||||||
else{
|
else if(isAlive(x,y) && (alive==2 || alive ==3)){
|
||||||
nextBoard[y] = nextBoard[y].substring(0, x) + board[y].charAt(x) + nextBoard[y].substring(x+1);
|
nextBoard[y] = nextBoard[y].substring(0, x) + board[y].charAt(x) + nextBoard[y].substring(x+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,18 @@ public class LifeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void keepAliveCell() {
|
public void keepAliveCell() {
|
||||||
|
//Eine lebende Zelle mit zwei oder drei lebenden Nachbarn bleibt in der Folgegeneration am Leben.
|
||||||
|
// Arrange: drei lebende Zellen
|
||||||
|
Life l = new Life();
|
||||||
|
l.setAlive(0, 0);
|
||||||
|
l.setAlive(0, 1);
|
||||||
|
l.setAlive(0, 2);
|
||||||
|
|
||||||
|
// Act: Berechnung der Folgegeneration
|
||||||
|
l.nextGeneration();
|
||||||
|
|
||||||
|
// Assert: Rasterpunkt mit zwei oder 3 lebenden Nachbarn bleibt am Leben
|
||||||
|
assertTrue(l.isAlive(0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user