From f6a2f009da39d5ed07355eaac95a499cc77d6821 Mon Sep 17 00:00:00 2001 From: Alexander Hartung Date: Fri, 4 Feb 2022 21:55:24 +0100 Subject: [PATCH] Add Shuffel for CardDeck --- src/main/java/solitaer/CardDeck.java | 6 ++++++ src/main/java/solitaer/SolitaerGamePanel.java | 1 + 2 files changed, 7 insertions(+) diff --git a/src/main/java/solitaer/CardDeck.java b/src/main/java/solitaer/CardDeck.java index 41a6518..3b49bdf 100644 --- a/src/main/java/solitaer/CardDeck.java +++ b/src/main/java/solitaer/CardDeck.java @@ -1,6 +1,7 @@ package solitaer; import java.util.ArrayList; +import java.util.Collections; public class CardDeck { @@ -33,4 +34,9 @@ public class CardDeck { return deck; } + + public void shuffelDeck() { + Collections.shuffle(deck); + } + } diff --git a/src/main/java/solitaer/SolitaerGamePanel.java b/src/main/java/solitaer/SolitaerGamePanel.java index 0edca74..26b1e18 100644 --- a/src/main/java/solitaer/SolitaerGamePanel.java +++ b/src/main/java/solitaer/SolitaerGamePanel.java @@ -48,6 +48,7 @@ public class SolitaerGamePanel extends JPanel { this.addMouseListener(mouseL); deck = new CardDeck(); + deck.shuffelDeck(); for (int i = 0; i < STARTSTACK_SIZE; i++) { int y = setLayouty(1);