Advertisement
richarduie

Deck.java

Mar 31st, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. /*
  2.  * Deck class contains info about constant properties general to the
  3.  * Card elements of all decks.
  4.  */
  5.  
  6. import java.util.Hashtable;
  7.  
  8. public class Deck
  9. {
  10.     private static final String[] SUITS = {
  11.         "Clubs", "Diamonds", "Hearts", "Spades"
  12.     };
  13.     private static final String[] NAMES = {
  14.         "Ace", "Two", "Three", "Four", "Five", "Six", "Seven",
  15.         "Eight", "Nine", "Ten", "Jack", "Queen", "King"
  16.     };
  17.     private static final int[] POINTS = {
  18.         1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10
  19.     };
  20.     private static final Hashtable<String, Integer> CARDS =
  21.         new Hashtable<String, Integer>();
  22.  
  23.     // constructor - loads CARDS Hashtable
  24.     public Deck() {
  25.         int lastI = NAMES.length;
  26.         int lastJ = SUITS.length;
  27.         for (int i = 0; i < lastI; i++) {
  28.             for (int j = 0; j < lastJ; j++) {
  29.                 String key = NAMES[ i ] + " of " + SUITS[ j ];
  30.                 Integer value = new Integer( POINTS[ i ]);
  31.                 CARDS.put( key, value);
  32.             }
  33.         }
  34.     }
  35.  
  36.     public static String[] getNAMES() {
  37.         return NAMES;
  38.     }
  39.  
  40.     public static String[] getSUITS() {
  41.         return SUITS;
  42.     }
  43.  
  44.     public Hashtable<String, Integer> getCARDS() {
  45.         return CARDS;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement