Lab 11

1. Playing Cards

The goal of this lab is to create a basic working deck of playing cards. Write an enum for Rank, which contains the card values
ACE, TWO, ..., QUEEN, KING; and another enum Suit, containing the four card suits.

Using these enums, write a class for a single Card, which will have private fields for its rank and suit, which are set by the constructor. Give the Card class getRank and getSuit basic getter methods for these, as well as a toString method (implement this in any reasonable way you wish). Recall the default toString for enums give you sensible strings already so it isn't necessary to write those.

Create a Deck class that has a field for an ArrayList of Cards, and in the Deck’s constructor you should initialize the list and fill it up with 52 different Card objects. Note to instantiate all the different cards you can use a nested loop going over the values methods of Suit and Rank. Write a shuffle class method that simply uses Collections.shuffle to shuffle the cards, an isEmpty method that returns true only if the list of cards is empty, and a draw method that removes and returns the last Card in the Deck.

Having this all set up, write a main program to create a single Deck, shuffle it, then draw cards and print them out until the deck is empty. In total there should be five classes, counting enums.