summaryrefslogtreecommitdiffstats
path: root/Java/BlackJack/Deck.java
diff options
context:
space:
mode:
Diffstat (limited to 'Java/BlackJack/Deck.java')
-rw-r--r--Java/BlackJack/Deck.java38
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.
+
+ }
+
+ }
+}