Browse Source

4gewinnt: added clearField method

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

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

@ -30,6 +30,10 @@ public class Logic {
return this.board[row][column];
}
public void clearField() {
this.setField(0, 0, 0);
}
public int getBoardSize() {
return this.board.length;
}
@ -230,6 +234,6 @@ public class Logic {
}
public void gameover() {
setPlayer1Score(10);
setPlayer1Score(calcScore());
}
}

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

@ -184,7 +184,16 @@ class LogicTest {
testObj.gameover();
assertEquals(10, testObj.getPlayer1Score());
assertEquals(1010, testObj.getPlayer1Score());
}
@Test
void clearFieldTest() {
testObj.setField(1, 0, 0);
testObj.clearField();
assertEquals(0, testObj.getField(0, 0));
}
@Test

Loading…
Cancel
Save