1 // Open Hold em is a java-based, server and client environment for hosting
2 // your own texas hold poker tournaments, and regular tables. It is full
3 // customizable and deployable in a number of different java-based hosting
4 // environments.
5 // Copyright (C) 2005 Chris A. Mattmann <chris@baron.pagemewhen.com>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // $Id: Deck.java,v 1.2 2005/08/07 02:48:35 mattmann Exp $
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 //construct all 52 cards in here
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 }