public class SuitDemo
1: /** A demonstration of the enumeration Suit.
2: @author Frank M. Carrano
3: @author Timothy M. Henry
4: @version 4.0
5: */
6: public class SuitDemo
7: {
8: private enum Suit
9: {
10: CLUBS("black"), DIAMONDS("red"), HEARTS("red"), SPADES("black");
11:
12: private final String color;
13:
14: private Suit(String suitColor)
15: {
16: color = suitColor;
17: } // end constructor
18:
19: public String getColor()
20: {
21: return color;
22: } // end getColor
23: } // end Suit
24:
25: public static void main(String[] args)
26: {
27: for (Suit nextSuit : Suit.values())
28: {
29: System.out.println(nextSuit + " are " + nextSuit.getColor() +
30: " and have an ordinal value of " +
31: nextSuit.ordinal());
32: } // end for
33: } // end main
34: } // end SuitDemo