package fivecardstud;
import java.util.List;

public class Deck {
    int deckSize;
    List usedCardIndex;
    Card[] deck;
    String[] values = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack",
        "Queen", "King", "Ace"};
    String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"};
    
    public Deck() {
        this.deckSize = 52;
        this.deck = new Card[deckSize];
        
        // iterate through values and suites to create each card
        int i = 0;
        for (String suit: suits){
            for (String value : values){
                deck[i] = new Card(value, suit);
                i++;
            }
        }
    }
    
    public Card[] shuffle(){
        int rand;
        Card temp;
        
        // swap the card at index i with any later card
        for (int i=0; i<deckSize; i++){
            rand = i + (int)(Math.random() * ((deckSize-1 - i) + 1));
            temp = deck[i];
            this.deck[i] = deck[rand];
            deck[rand] = temp;
        }
        return deck;
    }
    
    public Card[] deal(int toDeal, int players){
        Card[] hand;
        hand = new Card[toDeal];
        int i = 0;
        int j = 0;
        while (j<toDeal){
            if(usedCardIndex.contains(i)){
                i++;
            } else {
                usedCardIndex.add(i);
                hand[j] = deck[i];
                i+=players;
                j++;
            }
        }
        return hand;
    }
}
@@ -1142,24 +1142,25 @@
 oDeal%5D;%0A
+%0A
         
 int i = 
@@ -1147,34 +1147,64 @@
 %5D;%0A%0A        
-int i = 0;
+// check to see if card is already dealt
 %0A        int
@@ -1203,16 +1203,23 @@
      int
+ i = 0,
  j = 0;%0A
@@ -1244,16 +1244,62 @@
 oDeal)%7B%0A
+            // if card already used...iterate%0A
         
@@ -1346,32 +1346,104 @@
            i++;%0A
+            // if card is unused, use it, add to used list, iterate all%0A
             %7D el

comment card.deal