mirror of
https://gitlab.com/arnekeller/kit-programmieren-ws1920-final2.git
synced 2024-11-08 09:50:38 +00:00
Add shack building test and fix behaviour on codetester
This commit is contained in:
parent
3bd70a5350
commit
74cac150fa
17
shack_test_input.txt
Normal file
17
shack_test_input.txt
Normal file
@ -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
|
21
shack_test_output.txt
Normal file
21
shack_test_output.txt
Normal file
@ -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
|
@ -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();
|
||||
|
@ -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<Card> 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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user