From c57f31ac025346a9f0ad5671871ffbd96eb8de57 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Sun, 6 Feb 2022 15:54:29 +0100 Subject: [PATCH] Add clearStack methode to BaseStack --- src/main/java/solitaer/BaseStack.java | 4 ++++ src/main/java/solitaer/SolitaerGamePanel.java | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/solitaer/BaseStack.java b/src/main/java/solitaer/BaseStack.java index a94321d..5e78f37 100644 --- a/src/main/java/solitaer/BaseStack.java +++ b/src/main/java/solitaer/BaseStack.java @@ -24,6 +24,10 @@ public abstract class BaseStack extends JPanel { } offset = 0; } + + public void clearStack() { + stack.clear(); + } public boolean stackIsEmpty() { return stack.isEmpty(); diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 7c9e70a..9a4bc87 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -42,7 +42,7 @@ public class SolitaerGamePanel extends JPanel { this.add(label); save = new SaveStack(Offset_x_Save, Offset_y_Save); - this.add(save); + mouseL = new MyMouseListener(save); this.addMouseListener(mouseL); @@ -121,6 +121,7 @@ public class SolitaerGamePanel extends JPanel { deck.shuffelDeck(); for (int i = 0; i < STARTSTACK_SIZE; i++) { + start[i].clearStack(); int tmp = i; while (tmp != 0) { start[i].addCard(deck.getDeck().remove(0)); @@ -136,10 +137,12 @@ public class SolitaerGamePanel extends JPanel { for (int i = 0; i < ABLAGESTACK_SIZE; i++) { + ablage[i].clearStack(); this.add(ablage[i]); } - + geber.clearStack(); + waste.clearStack(); while (deck.getDeck().size() != 1) { geber.addCard(deck.getDeck().remove(0)); } @@ -150,6 +153,10 @@ public class SolitaerGamePanel extends JPanel { this.add(waste); this.add(geber); + + + save.clearStack(); + this.add(save);