// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package classes.enum5;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Demo {
	public static enum Suit { Spade, Heart, Club, Diamond }
	public static enum Value {Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace }
	public static class Card {
		private Suit suit;
		private Value value;
		public Card(Suit suit, Value value) {
			this.suit = suit;
			this.value = value;
		}
		public Suit getSuit() {
			return suit;
		}
		public Value getValue() {
			return value;
		}
		@Override
		public String toString() {
			return String.format("(%s,%s)",  suit, value);
		}
	}
	private static Random rng = new Random();
	public static void main(String[] args) {
		List<Card> deck = new ArrayList<Card>();
		for(Suit s : Suit.values()) {
			for(Value v : Value.values()) {
				deck.add(new Card(s, v));
			}
		}
		System.out.println(deck.get(rng.nextInt(deck.size())));
	}
}
