From c620449f0f5757d547e3daa43736928843a41766 Mon Sep 17 00:00:00 2001 From: neumeiermo84285 Date: Fri, 17 Dec 2021 13:39:11 +0100 Subject: [PATCH] LifeTest third step passed --- .../GameOfLifeAssignment/Life.class | Bin 3511 -> 3536 bytes out/test/GameOfLifeAssignment/LifeTest.class | Bin 993 -> 1067 bytes src/Life.java | 2 +- test/LifeTest.java | 12 ++++++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/out/production/GameOfLifeAssignment/Life.class b/out/production/GameOfLifeAssignment/Life.class index 7ed1173346015b2edcb9f128e22f7bbc1cae476c..51e30627e3be68fa6f4e5c7a6a827bc7b5b3e926 100644 GIT binary patch delta 200 zcmdlkeL;G|FHX+g4D1Z73=9lkCNp!X3+`ezV-aQ9#K0_Tw2eVx5yO(n)?6lxnUf2+ zbcAiRL|J6FF$B$IFp_4S&%hzgwqWvXE*fp75Qdu!!3_5qQWzdHq%yo_NMrcKkj{_W=tUa59U?Uh~HmfnYA&Y$v0QD zl&Wd%5f9wbMX2zkewTnPUg@ba%cqp@=q~Wa9V?``)~kyBQ_ONBzc@)aCT$T}8UkT4 M(dfWVM%hy8ACd(yOaK4? diff --git a/out/test/GameOfLifeAssignment/LifeTest.class b/out/test/GameOfLifeAssignment/LifeTest.class index cafc26e9669fc8c381a039165dcc241545fce480..91b85cfb0a6521d88c10513d9de06db9267552d7 100644 GIT binary patch delta 75 zcmaFJzM5l06!T;oCQU5lXo&}008#345$DA delta 27 hcmZ3@@sNE(6!YYl%#w`SlbKl*C*NmQW;6h@Gyr~t2eSYG diff --git a/src/Life.java b/src/Life.java index a2c2759..caf62b4 100644 --- a/src/Life.java +++ b/src/Life.java @@ -92,7 +92,7 @@ public class Life implements ILife { else if(isAlive(x,y) && alive < 2){ 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); } } diff --git a/test/LifeTest.java b/test/LifeTest.java index ba3d9e7..5631c4f 100644 --- a/test/LifeTest.java +++ b/test/LifeTest.java @@ -40,6 +40,18 @@ public class LifeTest { @Test 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)); }