1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package com.openholdem.structs;
24
25 import java.util.Hashtable;
26 import java.util.List;
27 import java.util.Vector;
28 import java.util.Iterator;
29
30 /***
31 * @author mattmann
32 * @version $Revision: 1.2 $
33 *
34 * <p>A Deck of 52 playing cards.</p>
35 *
36 */
37 public class Deck {
38
39 private Hashtable cardDeck = null;
40 public static String [] cards = {"A","K","Q","J","10","9","8","7","6","5","4","3","2"};
41
42
43 /***
44 *
45 */
46 public Deck() {
47
48
49 cardDeck = new Hashtable();
50
51 List suits = new Vector();
52 suits.add(Card.SUIT_CLUBS);
53 suits.add(Card.SUIT_DIAMONDS);
54 suits.add(Card.SUIT_HEARTS);
55 suits.add(Card.SUIT_SPADES);
56
57 for(Iterator i = suits.iterator(); i.hasNext(); ){
58 String suit = (String)i.next();
59
60 for(int j = 0; j < cards.length; j++){
61 Card c = new Card(suit,cards[j]);
62 cardDeck.put(c.toString(),c);
63 }
64 }
65
66 }
67
68 public Card getCard(String cardStr){
69 return (Card)cardDeck.get(cardStr);
70 }
71
72 public Card getCard(String card, String suit){
73 return getCard(card+suit);
74 }
75
76 /***
77 * @return Returns the cardDeck.
78 */
79 public Hashtable getCardDeck() {
80 return cardDeck;
81 }
82
83 /***
84 * @param cardDeck The cardDeck to set.
85 */
86 public void setCardDeck(Hashtable cardDeck) {
87 this.cardDeck = cardDeck;
88 }
89
90 }