From 74cac150fa262a9a9142d4b9ccfc995dd575ed95 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Sat, 29 Feb 2020 08:47:20 +0100 Subject: [PATCH] Add shack building test and fix behaviour on codetester --- shack_test_input.txt | 17 +++++++++++++++++ shack_test_output.txt | 21 +++++++++++++++++++++ src/edu/kit/informatik/MainTest.java | 5 +++++ src/edu/kit/informatik/model/CardGame.java | 5 +++-- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 shack_test_input.txt create mode 100644 shack_test_output.txt diff --git a/shack_test_input.txt b/shack_test_input.txt new file mode 100644 index 0000000..ef752c1 --- /dev/null +++ b/shack_test_input.txt @@ -0,0 +1,17 @@ +start wood,metal,plastic,wood,metal,plastic,spider,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,wood,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,metal,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,plastic,spider,spider,spider,spider,snake,snake,snake,snake,snake,tiger,tiger,tiger,tiger,tiger,thunderstorm +draw +draw +draw +draw +draw +draw +list-resources +list-buildings +build? +build shack +list-buildings +draw +start wood +rollD4 1 +list-resources +quit diff --git a/shack_test_output.txt b/shack_test_output.txt new file mode 100644 index 0000000..5612204 --- /dev/null +++ b/shack_test_output.txt @@ -0,0 +1,21 @@ +OK +wood +metal +plastic +wood +metal +plastic +plastic +metal +wood +plastic +metal +wood +EMPTY +shack +OK +shack +spider +Error, invalid start arguments +lose +metal diff --git a/src/edu/kit/informatik/MainTest.java b/src/edu/kit/informatik/MainTest.java index 592b626..d1a9f09 100644 --- a/src/edu/kit/informatik/MainTest.java +++ b/src/edu/kit/informatik/MainTest.java @@ -23,6 +23,11 @@ class MainTest { cmpInOut("commands1_input.txt", "commands1_output.txt"); } + @Test + void shackTest() throws IOException { + cmpInOut("shack_test_input.txt", "shack_test_output.txt"); + } + private void cmpInOut(String in, String out) throws IOException { System.setIn(new ByteArrayInputStream(readFile(in))); ByteArrayOutputStream output = new ByteArrayOutputStream(); diff --git a/src/edu/kit/informatik/model/CardGame.java b/src/edu/kit/informatik/model/CardGame.java index f6d2e2a..cc0faf5 100644 --- a/src/edu/kit/informatik/model/CardGame.java +++ b/src/edu/kit/informatik/model/CardGame.java @@ -1,5 +1,6 @@ package edu.kit.informatik.model; +import edu.kit.informatik.Terminal; import edu.kit.informatik.ui.InvalidInputException; import java.util.ArrayDeque; @@ -34,7 +35,7 @@ public class CardGame { * @return */ public boolean start(Deque cardStack) { - if (this.cardStack == null || this.cardStack.isEmpty()) { + if (this.cardStack == null) { this.cardStack = cardStack; return true; } else { @@ -107,7 +108,7 @@ public class CardGame { } else if (canBuild(item)) { // remove used resources for (Card resource : item.resourcesNeeded()) { - assert resources.removeLastOccurrence(resource); // TODO: remove assert + resources.removeLastOccurrence(resource); } items.add(item); if (item.equals(STEAMBOAT) || item.equals(BALLOON)) {