Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.ArrayList;
  2.    import java.util.Collections;
  3.  
  4.    public class Deck extends ArrayList<Card>
  5.    {
  6.       private static int deckMultiplier;
  7.       public static boolean aceHigh;
  8.       public static boolean kingHigh;
  9.    
  10.       public Deck(int deckMultiplier)
  11.       {
  12.          this.deckMultiplier = deckMultiplier;
  13.          if(deckMultiplier > 0)
  14.          {
  15.             int cardIndex = 0;
  16.            
  17.             for(int suit = 0; suit <= 3; suit++)
  18.             {
  19.                for(int rank = 1; rank <= 13; rank++)
  20.                {
  21.                   //Card temp = new Card(rank, suit);
  22.                   this.add((Card)new Card(rank, suit));
  23.                   cardIndex++;
  24.                }
  25.             }
  26.            
  27.          }
  28.        
  29.        
  30.       }
  31.    
  32.       public boolean shuffleDeck()
  33.       {
  34.          if(this.size() > 0)
  35.          {
  36.             Collections.shuffle(this);
  37.             return true;
  38.          }
  39.          else {
  40.             return false;
  41.          }
  42.       }
  43.       public static void AceHigh()
  44.       {
  45.          aceHigh = true;
  46.       }
  47.        
  48.       public static void KingHigh()
  49.       {
  50.          kingHigh = true;
  51.       }
  52.                 // this is just for testing.
  53.       public static void main(String args[]) throws Exception
  54.       {
  55.          Deck newDeck = new Deck(1);
  56.       }
  57.    }