# problem1.txt # Dan R. K. Ports # 6.170 PS1-1, 2004/02/07 1. CLUBS, DIAMONDS, HEARTS, and SPADES are static so that one object corresponding to each suit is created as part of the class, rather than as part of each CardSuit object. 2. Using a separate class rather than integer constants makes it possible to distinguish a card suit from any other integer value. It also allows other methods to be added (for suit icons, etc). 3. this can not be null. If the constructor or some other method is being called, then it is referring to some object, and the this pointer is set. 4. The constructors are private so that no CardValue or CardSuit objects can be instantiated except for the static variables in the class. 5. The only CardValue and CardSuit objects are the static variables created in their respective classes, which are all different, so comparing the addresses (as the default Object.equals method does) is an acceptable test for equality. 6. Implementing the Comparable interface allows the Java Collections framework to understand the proper ordering of CardValue and CardSuit objects, and thus makes it easy to sort them. 7. The ordering of a Deck is significant (since decks of cards are shuffled, dealt from, etc). Thus, it is necessary to use an unsorted collection to represent one. A Hand does not have any particular ordering, and the cards are generally returned in sorted order, so it is reasonable to use a sorted collection.