|
@ -21,7 +21,9 @@ class LogicTest { |
|
|
matchfield = new Matchfield(size); |
|
|
matchfield = new Matchfield(size); |
|
|
matchfield.createMatchfield(); |
|
|
matchfield.createMatchfield(); |
|
|
logic.setMatchfield(matchfield); |
|
|
logic.setMatchfield(matchfield); |
|
|
Coordinate calcResult = logic.chooseField(); |
|
|
|
|
|
|
|
|
ArrayList<Coordinate> everySecondField = logic.getEverySecondField(); |
|
|
|
|
|
|
|
|
|
|
|
Coordinate calcResult = logic.chooseField(everySecondField); |
|
|
assertNotNull(calcResult); |
|
|
assertNotNull(calcResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -34,14 +36,13 @@ class LogicTest { |
|
|
matchfield.createMatchfield(); |
|
|
matchfield.createMatchfield(); |
|
|
logic.setMatchfield(matchfield); |
|
|
logic.setMatchfield(matchfield); |
|
|
|
|
|
|
|
|
for (int x = 0; x < size; x++) { |
|
|
|
|
|
for (int y = 0; y < size; y++) { |
|
|
|
|
|
matchfield.setState(x, y, Coordinate.SHOT); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ArrayList<Coordinate> everySecondField = logic.getEverySecondField(); |
|
|
|
|
|
for (int i = 0; i < everySecondField.size(); i++) { |
|
|
|
|
|
everySecondField.get(i).setState(Coordinate.SHOT); |
|
|
} |
|
|
} |
|
|
matchfield.setState(2, 2, Coordinate.EMPTY); |
|
|
matchfield.setState(2, 2, Coordinate.EMPTY); |
|
|
|
|
|
|
|
|
Coordinate choosenField = logic.chooseField(); |
|
|
|
|
|
|
|
|
Coordinate choosenField = logic.chooseField(everySecondField); |
|
|
int calcState = matchfield.getState(choosenField.getX(), choosenField.getY()); |
|
|
int calcState = matchfield.getState(choosenField.getX(), choosenField.getY()); |
|
|
assertNotEquals(calcState, Coordinate.SHOT); |
|
|
assertNotEquals(calcState, Coordinate.SHOT); |
|
|
} |
|
|
} |
|
@ -191,4 +192,15 @@ class LogicTest { |
|
|
|
|
|
|
|
|
assertEquals(logic.getClearedLeft(), true); |
|
|
assertEquals(logic.getClearedLeft(), true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testConstructor() { |
|
|
|
|
|
Logic logic = new Logic(); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(logic.getFoundShip(), false); |
|
|
|
|
|
assertEquals(logic.getClearedAbove(), false); |
|
|
|
|
|
assertEquals(logic.getClearedBelow(), false); |
|
|
|
|
|
assertEquals(logic.getClearedLeft(), false); |
|
|
|
|
|
assertEquals(logic.getClearedRight(), false); |
|
|
|
|
|
} |
|
|
} |
|
|
} |