import java.awt.Color;
import java.util.ArrayList;
@author
public class EnumAdvanceTest {
@paramargs
public static void main(String[] args) {
ArrayList<Card> deck = new ArrayList<Card>();
for(Suit suit: Suit.values()){
for(CardValue value: CardValue.values()){
Card card = new Card(suit, value);
deck.add(card);
System.out.println(card);
}
}
}
}
class Card{
public final Suit suit;
public final CardValue value;
public Card(Suit s, CardValue v){
this.suit = s;
this.value = v;
}
public String toString(){
return value + " of " + suit;
}
}
enum Suit {
CLUBS(Color.BLACK), DIAMONDS(Color.RED),
HEARTS(Color.RED), SPADES(Color.BLACK);
private Color color;
Suit(Color color){
this.color = color;
}
public Color getColor(){
return color;
}
}
enum CardValue {
ACE(1, 1, 11), DEUCE(2, 2), THREE(3, 3), FOUR(4, 4),
FIVE(5, 5), SIX(6, 6), SEVEN(7, 7), EIGHT(8, 8),
NINE(9, 9), TEN(10, 10), JACK(11, 10), QUEEN(12, 10), KING(13, 10);
private int order;
private int value;
private int otherValue;
CardValue(int order, int value){
this.order = order;
this.value = value;
this.otherValue = -1;
}
CardValue(int order, int value, int otherValue){
this.order = order;
this.value = value;
this.otherValue = otherValue;
}
public int getOrder(){
return order;
}
public int getValue(){
return value;
}
public int getOtherValue(){
return otherValue;
}
public boolean hasOtherValue(){
return (otherValue >= 0);
}
}