diff options
author | msglm <msglm@techchud.xyz> | 2023-01-14 05:31:48 -0600 |
---|---|---|
committer | msglm <msglm@techchud.xyz> | 2023-01-14 05:31:48 -0600 |
commit | 9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch) | |
tree | eb1efc1d028b949dd83bb710c68be8eff58f26e7 /Java/BlackJack/Deck.java | |
download | school-code-master.tar.gz school-code-master.tar.bz2 school-code-master.zip |
Diffstat (limited to 'Java/BlackJack/Deck.java')
-rw-r--r-- | Java/BlackJack/Deck.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Java/BlackJack/Deck.java b/Java/BlackJack/Deck.java new file mode 100644 index 0000000..a828e52 --- /dev/null +++ b/Java/BlackJack/Deck.java @@ -0,0 +1,38 @@ +import java.util.Random; //for randomness
+public class Deck {
+
+ // data member
+ private int[] deckFace = new int[20];
+ private int[] deckSuit = new int[20];
+
+
+
+ // Constructors
+ //accepts suit and face
+ public Deck() {
+ for(int i=0;i<20;i++){
+ Random random = new Random();
+ deckFace[i] = random.nextInt(14); //1-10 are as expected, 11 is Jack, 12 is Queen, 13 is King, 14 is Joker
+ deckSuit[i] = random.nextInt(4); //Card order is highest to lowest. 1 is hearts 4 is spades.
+ }
+ }
+
+ void printDeck(){
+
+ for(int i=0;i<20;i++){
+ System.out.println("Card " + i + " has a Face of " + deckFace[i] + " and a Suit of " + deckSuit[i]);
+ }
+
+ }
+
+ void shuffle(){
+
+ for(int i=0;i<20;i++){
+ Random random = new Random();
+ deckFace[i] = random.nextInt(14); //1-10 are as expected, 11 is Jack, 12 is Queen, 13 is King, 14 is Joker
+ deckSuit[i] = random.nextInt(4); //Card order is highest to lowest. 1 is hearts 4 is spades.
+
+ }
+
+ }
+}
|