Browse Source

tictactoe: added method to get current player

tictactoe
Malte Schellhardt 3 years ago
committed by Lorenz Hohmann
parent
commit
1c687f496f
  1. 4
      src/main/java/de/tims/tictactoe/GameLogic.java
  2. 8
      src/test/java/de/tims/tictactoe/GameLogicTest.java

4
src/main/java/de/tims/tictactoe/GameLogic.java

@ -104,6 +104,10 @@ public class GameLogic implements ActionListener {
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];
this.contentPanel = new JPanel();

8
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) {

Loading…
Cancel
Save