Browse Source

4gewinnt: finished checkButtons method

4gewinnt
Steffen Helmke 3 years ago
committed by Lorenz Hohmann
parent
commit
645770c07c
  1. 6
      src/main/java/de/tims/viergewinnt/ai/Logic.java
  2. 15
      src/test/java/de/tims/viergewinnt/ai/LogicTest.java

6
src/main/java/de/tims/viergewinnt/ai/Logic.java

@ -87,7 +87,11 @@ public class Logic {
}
public boolean checkButtons() {
return true;
boolean res = false;
for(int i = 0; i < buttons.length; i++) {
res = buttons[i].isEnabled() | res;
}
return res;
}
JPanel contentPanel;

15
src/test/java/de/tims/viergewinnt/ai/LogicTest.java

@ -227,7 +227,7 @@ class LogicTest {
}
@Test
void checkButtonsTest() {
void checkButtonsTestTrue() {
testObj.create4gewinntGui();
boolean expectedResult = true;
@ -236,6 +236,19 @@ class LogicTest {
assertEquals(expectedResult, realResult);
}
@Test
void checkButtonsTestFalse() {
testObj.create4gewinntGui();
boolean expectedResult = false;
for(int i = 0; i < testObj.buttons.length; i++) {
testObj.buttons[i].setEnabled(false);
}
boolean realResult = testObj.checkButtons();
assertEquals(expectedResult, realResult);
}
private static Stream<Arguments> playfieldResults() {
int[][] playfield1 = {{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0},

Loading…
Cancel
Save