Advertisement
Guest User

Untitled

a guest
Sep 21st, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1.  
  2. public class Main {
  3.     public static void main(String[] args) {
  4.      Deck d = new Deck();
  5.         d.createDeck();
  6.         System.out.println(d);
  7.  
  8. }
  9.  
  10. }
  11. import java.util.ArrayList;
  12.  
  13. public class Deck {
  14.  
  15.     private ArrayList<Cards> deck;
  16.  
  17.     public Deck() {
  18.         this.deck = new ArrayList<>();
  19.     }
  20.     public void createDeck(){
  21.         for (CardValue cv : CardValue.values()) {
  22.             for (Suits ss : Suits.values()) {
  23.                 this.deck.add(new Cards(cv, ss));
  24.  
  25.             }
  26.         }
  27.  
  28.     }
  29.  
  30.     public String toString () {
  31.         String Cardout = " ";
  32.         for (Cards d : this.deck) {
  33.             Cardout =  d.toString();
  34.         }
  35.         return Cardout;
  36.  
  37.     }
  38. }
  39.  
  40.  
  41. public class Cards {
  42.  
  43.     private CardValue values;
  44.     private Suits suits;
  45.  
  46.     Cards(CardValue v, Suits s) {
  47.         this.values = v;
  48.         this.suits = s;
  49.  
  50.     }
  51.  
  52.     public String toString(){
  53.  
  54.         return this.values.toString() + " of " + this.suits.toString();
  55.     }
  56. }
  57.  
  58. public enum Suits {
  59.  
  60.     Diamond, Hears, Clubs, Spades
  61.  
  62. }
  63. public enum CardValue
  64. {
  65.     TWO(2),
  66.     THREE(3),
  67.     FOUR(4),
  68.     FIVE(5),
  69.     SIX(6),
  70.     SEVEN(7),
  71.     EIGHT(8),
  72.     NINE(9),
  73.     TEN(10),
  74.     JACK(10),
  75.     QUEEN(10),
  76.     KING(10),
  77.     ACE(11);
  78.  
  79.     private int cardValue;
  80.  
  81.     private CardValue (int value)
  82.     {
  83.         this.cardValue = value;
  84.     }
  85.  
  86.     public int getCardValue() {
  87.         return cardValue;
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement