From ce2f8ddd8b20b42e213ff306c043efd81f662d4e Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Tue, 18 Jan 2022 17:03:59 +0100 Subject: [PATCH] 4gewinnt: added gameover method --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 4 ++++ src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 85ec410..5135a1c 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -220,4 +220,8 @@ public class Logic { } return score; } + + public void gameover() { + setPlayer1Score(10); + } } diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index 1c9a2f5..d423d58 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -178,6 +178,15 @@ class LogicTest { assertEquals(expectedResult, realResult); } + @Test + void gameoverTest() { + testObj.setField(1, 0, 0); + + testObj.gameover(); + + assertEquals(10, testObj.getPlayer1Score()); + } + private static Stream playfieldResults() { int[][] playfield1 = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},