|
@ -112,4 +112,23 @@ class MatchfieldShipTest { |
|
|
boolean calulatedResult = matchfield.areAllShipsHit(); |
|
|
boolean calulatedResult = matchfield.areAllShipsHit(); |
|
|
assertTrue(calulatedResult); |
|
|
assertTrue(calulatedResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void testIfAllShipsHitReturnsFalseWhenTwoShipsAreNotFullyHit() { |
|
|
|
|
|
Matchfield matchfield = new Matchfield(10); |
|
|
|
|
|
matchfield.createMatchfield(); |
|
|
|
|
|
|
|
|
|
|
|
matchfield.setShip(new Coordinate(0, 0), 5, 1); |
|
|
|
|
|
matchfield.getField(0, 0).setState(Coordinate.HIT); |
|
|
|
|
|
matchfield.getField(0, 1).setState(Coordinate.HIT); |
|
|
|
|
|
matchfield.getField(0, 2).setState(Coordinate.HIT); |
|
|
|
|
|
matchfield.getField(0, 3).setState(Coordinate.HIT); |
|
|
|
|
|
matchfield.getField(0, 4).setState(Coordinate.HIT); |
|
|
|
|
|
|
|
|
|
|
|
matchfield.setShip(new Coordinate(3, 4), 2, 0); |
|
|
|
|
|
matchfield.getField(4, 4).setState(Coordinate.HIT); |
|
|
|
|
|
|
|
|
|
|
|
boolean calulatedResult = matchfield.areAllShipsHit(); |
|
|
|
|
|
assertFalse(calulatedResult); |
|
|
|
|
|
} |
|
|
} |
|
|
} |