From f83db6a3f957e407e93ccc34bc4fb41b01645b48 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 30 Jan 2022 18:38:24 +0100 Subject: [PATCH] Add swapGeberWaste Funktion and Add Test --- src/main/java/solitaer/GeberStack.java | 11 ++++++++++ src/test/java/solitaer/GeberStackTest.java | 25 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/java/solitaer/GeberStackTest.java diff --git a/src/main/java/solitaer/GeberStack.java b/src/main/java/solitaer/GeberStack.java index 9e10e10..1136daa 100644 --- a/src/main/java/solitaer/GeberStack.java +++ b/src/main/java/solitaer/GeberStack.java @@ -19,6 +19,17 @@ public class GeberStack extends BaseStack { this.wasteStack = _waste; } + public WasteStack getWastStack() { + return wasteStack; + } + + public void swapWasteGeber() { + while(wasteStack.stackIsEmpty() == false) { + this.addCard(wasteStack.removeLastCard()); + } + } + + @Override protected boolean cardCheck(Card _topStack, Card _playerCard) { // TODO Auto-generated method stub diff --git a/src/test/java/solitaer/GeberStackTest.java b/src/test/java/solitaer/GeberStackTest.java new file mode 100644 index 0000000..0115389 --- /dev/null +++ b/src/test/java/solitaer/GeberStackTest.java @@ -0,0 +1,25 @@ +package solitaer; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class GeberStackTest { + + @Test + void testswapGeberWaste001() { + WasteStack waste = new WasteStack(0, 0); + GeberStack geber = new GeberStack(0, 0, waste); + + for (int i = 1; i < 14; i++) { + waste.addCard(new Card(0, Symbol.Pik, false)); + } + + int expectedResult = waste.stackSize(); + + geber.swapWasteGeber(); + + assertEquals(geber.stackSize(), expectedResult, "same Size"); + } + +}