diff --git a/commands1_output.txt b/commands1_output.txt index e5ab76e..74341d7 100644 --- a/commands1_output.txt +++ b/commands1_output.txt @@ -4,7 +4,7 @@ Error, can not get buildings: game not started Error, can not get resources: game not started Error, invalid list-buildings argument: none expected Error, invalid list-resources argument: none expected -OK +Error, can not reset a game that is not started! Error, invalid reset argument: none expected Error, not expecting dice roll Error, invalid start argument value(s) diff --git a/src/edu/kit/informatik/Main.java b/src/edu/kit/informatik/Main.java index 389c091..17191b5 100644 --- a/src/edu/kit/informatik/Main.java +++ b/src/edu/kit/informatik/Main.java @@ -3,6 +3,18 @@ package edu.kit.informatik; import edu.kit.informatik.ui.CommandLine; public final class Main { + /** + * Utility class -> private constructor. + */ + private Main() { + + } + + /** + * Program entry point. + * + * @param args command-line arguments + */ public static void main(String[] args) { CommandLine.startInteractive(); } diff --git a/src/edu/kit/informatik/model/CardGame.java b/src/edu/kit/informatik/model/CardGame.java index 86b5194..2cf7331 100644 --- a/src/edu/kit/informatik/model/CardGame.java +++ b/src/edu/kit/informatik/model/CardGame.java @@ -203,11 +203,13 @@ public class CardGame { } public void reset() { - if (cardStack != null) { + if (cardStack == null) { + throw new InvalidInputException("can not reset a game that is not started!"); + } else { this.currentCardStack = new ArrayDeque<>(cardStack); } - this.resources = new ArrayDeque<>(); - this.items = new ArrayList<>(); + this.resources.clear(); + this.items.clear(); this.fightingAnimal = false; this.awaitedDiceSize = null; this.minimumDiceRoll = null;