Browse Source

Add clearStack methode to BaseStack

feature_solitaer_MenueBar
Alexander Hartung 3 years ago
parent
commit
c57f31ac02
  1. 4
      src/main/java/solitaer/BaseStack.java
  2. 11
      src/main/java/solitaer/SolitaerGamePanel.java

4
src/main/java/solitaer/BaseStack.java

@ -24,6 +24,10 @@ public abstract class BaseStack extends JPanel {
} }
offset = 0; offset = 0;
} }
public void clearStack() {
stack.clear();
}
public boolean stackIsEmpty() { public boolean stackIsEmpty() {
return stack.isEmpty(); return stack.isEmpty();

11
src/main/java/solitaer/SolitaerGamePanel.java

@ -42,7 +42,7 @@ public class SolitaerGamePanel extends JPanel {
this.add(label); this.add(label);
save = new SaveStack(Offset_x_Save, Offset_y_Save); save = new SaveStack(Offset_x_Save, Offset_y_Save);
this.add(save);
mouseL = new MyMouseListener(save); mouseL = new MyMouseListener(save);
this.addMouseListener(mouseL); this.addMouseListener(mouseL);
@ -121,6 +121,7 @@ public class SolitaerGamePanel extends JPanel {
deck.shuffelDeck(); deck.shuffelDeck();
for (int i = 0; i < STARTSTACK_SIZE; i++) { for (int i = 0; i < STARTSTACK_SIZE; i++) {
start[i].clearStack();
int tmp = i; int tmp = i;
while (tmp != 0) { while (tmp != 0) {
start[i].addCard(deck.getDeck().remove(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++) { for (int i = 0; i < ABLAGESTACK_SIZE; i++) {
ablage[i].clearStack();
this.add(ablage[i]); this.add(ablage[i]);
} }
geber.clearStack();
waste.clearStack();
while (deck.getDeck().size() != 1) { while (deck.getDeck().size() != 1) {
geber.addCard(deck.getDeck().remove(0)); geber.addCard(deck.getDeck().remove(0));
} }
@ -150,6 +153,10 @@ public class SolitaerGamePanel extends JPanel {
this.add(waste); this.add(waste);
this.add(geber); this.add(geber);
save.clearStack();
this.add(save);

Loading…
Cancel
Save