/* Static import the constants for Problem1 */
import static java.lang.Math.*;

import java.util.*;

public class Step27 {
    
    public static void main (String args[]) {
        
        /* Problem 1 */
        System.out.println("Problem 1:");
        System.out.println("pi=" + java.lang.Math.PI);
        System.out.println("pi=" + PI);
        System.out.println("e=" + E);

        /* Problem 2 */
        System.out.println("\nProblem 2:");
        Deck d = new Deck();
        d.shuffle();
        System.out.print(d);
    }
}


/* Problem2 classes */

/* Card: uses enums for Rank and Suit */
class Card {
    public enum Rank { DEUCE, THREE, FOUR, FIVE, SIX,
                       SEVEN, EIGHT, NINE, TEN, JACK, 
                       QUEEN, KING, ACE }

    public enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES }

    private final Rank rank;
    private final Suit suit;
    
    public Card(Rank rank, Suit suit) {
        this.rank = rank;
        this.suit = suit;
    }

    public String toString() { return rank + " of " + suit; }
}

/* Deck: 52 cards */
class Deck {

    private Card[] cards = new Card[52];
    
    public Deck() {
        /* Create the deck by iterating through suits, ranks */
        int index = 0;
        for (Card.Suit suit : Card.Suit.values()) {
            for (Card.Rank rank : Card.Rank.values()) {
                cards[index] = new Card(rank, suit);
                index++;
            }
        }
    }
    
    public void shuffle() {
        /* Use some builtins for shuffling. Don't worry too much
           about this line. Collections.shuffle() requires a Collection,
           so we convert the array to a List, which implements Collection. */
        Collections.shuffle(Arrays.asList(cards));
    }

    public String toString() {
        String result = new String("");
        for (Card c: cards) {
            result += c + "\n";
        }
        return result;
    }
}
