From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- Java/BlackJack/Deck.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Java/BlackJack/Deck.java (limited to 'Java/BlackJack/Deck.java') 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. + + } + + } +} -- cgit v1.2.3