From 67d8df099b60c827670900ec2a95d30e96526767 Mon Sep 17 00:00:00 2001 From: Mohammad-Ali Date: Mon, 20 May 2019 19:27:07 -0400 Subject: [PATCH] Changed deck creation Changed deck creation to follow the example given by the college board instructions. In the current code, it assumes that the same number of ranks, suits and values are going to be given, but that is not true. Furtheremore my code creates a card of a given rank and value for every possible suit. --- Activity-2/Deck.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Activity-2/Deck.java b/Activity-2/Deck.java index 5af29aa..3ddac77 100644 --- a/Activity-2/Deck.java +++ b/Activity-2/Deck.java @@ -21,9 +21,10 @@ public class Deck { * @param values is an array containing all of the card point values. */ public Deck(String[] ranks, String[] suits, int[] values) { - for(int i = 0; i < ranks.length(); i++){ - Card card = new Card(ranks[i], suits[i], values[i]); //Creates new card by matching the params. - cards[i] = card; + for (int a = 0; a < ranks.length; a++){ + for (int b = 0; b < suits.length; b++) { + cards.add(new Card(ranks[a],suits[b],values[a])); + } } size = cards.size(); //Sets the size field to the size of the deck. }