Specifications

Sun Services
Java™ Programming Language
Module 7, slide 20 of 44
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
The New Enumerated Type
Using enumerated types is easy:
0
1 package cards.domain;
2
3 public class PlayingCard {
4
5 private Suit suit;
6 private int rank;
7
8 public PlayingCard(Suit suit, int rank) {
9 this.suit = suit;
10 this.rank = rank;
11 }
12
13 public Suit getSuit() {
14 return suit;
15 }