diff --git a/src/edu/kit/informatik/cardgame/model/Card.java b/src/edu/kit/informatik/cardgame/model/Card.java index bae7379..4aac4f1 100644 --- a/src/edu/kit/informatik/cardgame/model/Card.java +++ b/src/edu/kit/informatik/cardgame/model/Card.java @@ -1,12 +1,33 @@ package edu.kit.informatik.cardgame.model; public enum Card { + /** + * Wood. Basic resource. + */ WOOD, + /** + * Metal. Basic resource. + */ METAL, + /** + * Plastic. Basic resource. + */ PLASTIC, + /** + * Spider. Deadly animal. + */ SPIDER, + /** + * Snake. Dangerous animal. + */ SNAKE, + /** + * Tiger. Strong animal. + */ TIGER, + /** + * Thunderstorm. Lifts up items and blows them away. + */ THUNDERSTORM; public CardCategory category() { @@ -22,18 +43,10 @@ public enum Card { case THUNDERSTORM: return CardCategory.CATASTROPHE; default: - return null; + throw new IllegalArgumentException("no category defined for this card"); } } - public boolean isResource() { - return this.equals(WOOD) || this.equals(METAL) || this.equals(PLASTIC); - } - - public boolean needsDiceRoll() { - return this.diceSizeNeeded() > 0; - } - public int diceSizeNeeded() { switch (this) { case SPIDER: @@ -60,10 +73,6 @@ public enum Card { } } - public boolean isCatastrophe() { - return this.equals(THUNDERSTORM); - } - public int requiredAmount() { switch (this) { case WOOD: @@ -120,7 +129,7 @@ public enum Card { case THUNDERSTORM: return "thunderstorm"; default: - return null; + throw new IllegalArgumentException("toString not defined for this card value"); } } } diff --git a/src/edu/kit/informatik/cardgame/model/CardGame.java b/src/edu/kit/informatik/cardgame/model/CardGame.java index dd810ff..13cbb37 100644 --- a/src/edu/kit/informatik/cardgame/model/CardGame.java +++ b/src/edu/kit/informatik/cardgame/model/CardGame.java @@ -58,6 +58,8 @@ public class CardGame { clearResources(); items.remove(Item.FIREPLACE); break; + default: + throw new IllegalStateException("encountered unknown card category!"); } checkLost(); return card;