From 1c687f496fb47483c7d71aeb38e56536a636c6a9 Mon Sep 17 00:00:00 2001 From: Malte Schellhardt Date: Mon, 14 Feb 2022 23:14:53 +0100 Subject: [PATCH] tictactoe: added method to get current player --- src/main/java/de/tims/tictactoe/GameLogic.java | 4 ++++ src/test/java/de/tims/tictactoe/GameLogicTest.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/de/tims/tictactoe/GameLogic.java b/src/main/java/de/tims/tictactoe/GameLogic.java index e933b98..4c464fa 100644 --- a/src/main/java/de/tims/tictactoe/GameLogic.java +++ b/src/main/java/de/tims/tictactoe/GameLogic.java @@ -103,6 +103,10 @@ public class GameLogic implements ActionListener { public boolean checkEndOfGame() { return checkForWin(PLAYER_1) || checkForWin(PLAYER_2); } + + public char getCurrentPlayer() { + return 'x'; + } public JPanel generateGUI() { this.fields = new JButton[this.board.length][this.board.length]; diff --git a/src/test/java/de/tims/tictactoe/GameLogicTest.java b/src/test/java/de/tims/tictactoe/GameLogicTest.java index 276deb9..f939cff 100644 --- a/src/test/java/de/tims/tictactoe/GameLogicTest.java +++ b/src/test/java/de/tims/tictactoe/GameLogicTest.java @@ -81,6 +81,14 @@ class GameLogicTest { assertEquals(expectedResult, realResult); } + @Test + void getCurrentPlayerTest() { + char expectedResult = game.getCurrentPlayer(); + char realResult = 'x'; + + assertEquals(expectedResult, realResult); + } + @ParameterizedTest(name = "[{index}] {0} -> {2} fields") @MethodSource("testCasesForCountPlayfields") void fieldCountTest(String testName, int size, int expectedResult) {