001 package ps0.optional;
002
003 import java.util.Collection;
004 import java.util.LinkedList;
005
006 public class MyHand {
007 static LinkedList<Card> hand;
008
009 MyHand() {
010 hand = new LinkedList<Card>();
011
012 hand.add(new Card(CardValue.EIGHT, CardSuit.CLUBS));
013 hand.add(new Card(CardValue.TWO, CardSuit.CLUBS));
014 hand.add(new Card(CardValue.QUEEN, CardSuit.CLUBS));
015 hand.add(new Card(CardValue.NINE, CardSuit.SPADES));
016 hand.add(new Card(CardValue.KING, CardSuit.HEARTS));
017 hand.add(new Card(CardValue.QUEEN, CardSuit.HEARTS));
018 hand.add(new Card(CardValue.SEVEN, CardSuit.HEARTS));
019 }
020
021 public static void main(String[] args) {
022 MyHand myhand = new MyHand();
023 myhand.printHand(hand);
024 myhand.sortSmallestToLargest();
025 System.out.println("\nAfter sorting from smallest to largest:");
026 myhand.printHand(hand);
027 myhand.sortLargesttoSmallest();
028 System.out.println("\nAfter sorting from largest to smallest:");
029 myhand.printHand(hand);
030 System.out.println("\nHearts in hand:");
031 myhand.printHand_OnlyHearts(hand);
032 System.out.println("\nHand after removing faces:");
033 myhand.printHand_RemoveFaceCards(hand);
034 }
035
036 /**
037 * Print the contents of a hand of cards to the screen. [Note:
038 * one can also System.out.println to print the contents of
039 * arrays]
040 */
041 public void printHand(Collection<Card> hand) {
042 // Your code here.
043 }
044
045 /**
046 * Sorts the cards so that any subsequent calls to printHand
047 * will print the Hand from the smallest to the largest.
048 */
049 public void sortSmallestToLargest() {
050 // Your code here.
051 }
052
053 /**
054 * Sorts the cards so that any subsequent calls to printHand
055 * will print the Hand from the largest to the smallest.
056 */
057 public void sortLargesttoSmallest() {
058 // Your code here.
059 }
060
061 /**
062 * Print only the cards in hand that are hearts
063 */
064 public void printHand_OnlyHearts(Collection<Card> hand) {
065 // Your code here.
066 }
067
068 /**
069 * Print only the cards in hand that are number cards AND remove face cards
070 * from hand
071 */
072 public void printHand_RemoveFaceCards(Collection<Card> hand) {
073 // Your code here.
074 }
075
076 }