Lab
Adding a Shuffle Method to the Deck Class
Introduction:
You implemented a Deck class in Activity 2. This class should be complete except for the shuffle method. You also implemented a DeckTester class that you used to test your incomplete Deck class.
In Activity 3, you implemented methods in the Shuffler class, which shuffled integers.
Now you will use what you learned about shuffling in Activity 3 to implement the Deck shuffle
method.
Exercises:
1.The file Deck.java, found in the Activity 4 Starter Code folder, is a correct solution from Activity 2. Complete the Deck class by implementing the shuffle method. Use the efficient selection shuffle algorithm from Activity 3.
Note that the Deck constructor creates the deck and then calls the shuffle method. The shuffle method also needs to reset the value of size to indicate that all of the cards can be dealt again.
2.The DeckTester.java file, found in the Activity4 Starter Code folder, provides a basic set of Deck tests. It is similar to the DeckTester class you might have written in Activity 2. Add additional code at the bottom of the main method to create a standard deck of 52 cards and test the shuffle method. You can use the Deck toString method to “see” the cards after every shuffle.
Teacher’s Comments: