/* * Deck.java */ package boondock.holdem.Cards; import java.util.*; /** * Class that develops and manipulates a deck of cards. * * @author Jonathan O'Keefe * @author Scott Semonian * @author Matt Brinza * @author Hamid R. Tahsildoost * * @author The Boondock Saints * @author No Limit Texas Holdem */ public class Deck{ private List cards; private ListIterator deck; /** * Sets up a new, shuffled Deck of Cards */ public Deck (){ Card cardArray[] = new Card[52]; for( int cnt=0; cnt < 52; cnt++ ) cardArray[cnt] = new Card( cnt ); cards = Arrays.asList( cardArray ); Collections.shuffle( cards ); deck = cards.listIterator(); } /** * Sets up a new, shuffled Deck of Cards * @param numDecks The number of Decks in play */ public Deck (int numDecks){ Card cardArray[] = new Card[52*numDecks]; for( int cnt=0; cnt < 52*numDecks; cnt++ ) cardArray[cnt] = new Card( cnt ); cards = Arrays.asList( cardArray ); Collections.shuffle( cards ); deck = cards.listIterator(); } /** * Deals the next Card * @return Next card in Deck */ public Card nextCard (){ return (Card)deck.next(); } /** * Shuffles the Deck */ public void shuffle(){ Collections.shuffle( cards ); deck = cards.listIterator(); } /** * Gets previous card from the deck (obsolete) * @return Previous card in deck. */ public Card previousCard (){ return (Card)deck.previous(); } }