Redo if statement with exception throwing
This commit is contained in:
parent
3049650bc4
commit
c16ddc6bca
|
@ -32,6 +32,9 @@ public class SiedlerGame {
|
||||||
* or players is not between two and four
|
* or players is not between two and four
|
||||||
*/
|
*/
|
||||||
public SiedlerGame(int winPoints, int numberOfPlayers) {
|
public SiedlerGame(int winPoints, int numberOfPlayers) {
|
||||||
|
if (winPoints < 3 || numberOfPlayers < Config.MIN_NUMBER_OF_PLAYERS || numberOfPlayers > 4) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
bank = new Bank();
|
bank = new Bank();
|
||||||
board = new SiedlerBoard();
|
board = new SiedlerBoard();
|
||||||
board.createFixGameField();
|
board.createFixGameField();
|
||||||
|
|
|
@ -152,7 +152,6 @@ public class SiedlerGameTest {
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("Starting Siedler game with one player, expects fail")
|
@DisplayName("Starting Siedler game with one player, expects fail")
|
||||||
public void startSiedlerGameWithLowerThanMinimumWinPoints() {
|
public void startSiedlerGameWithLowerThanMinimumWinPoints() {
|
||||||
|
|
||||||
Exception exc = assertThrows(IllegalArgumentException.class, () -> {
|
Exception exc = assertThrows(IllegalArgumentException.class, () -> {
|
||||||
SiedlerGame game = new SiedlerGame(1, 4);
|
SiedlerGame game = new SiedlerGame(1, 4);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue