On the class web page, at the following URL
http://rocky.colby.edu/cs231/code/hw1/Card.javayou will find a program named Card.java that creates a deck of playing cards and tests a few simple algorithms, like shuffling the deck, sorting the deck, and searching for a card in the deck (using a bisection search).
In this program, a deck is implemented as an array of Cards. For example, when we pass a ``deck'' as a parameter, the actual type of the parameter is Card[].
In Chapter 12 of the excellent textbook, ``How to think like a computer scientist,'' I present an alternative representation for a deck, an object type named Deck that contains an array of cards as an instance variable.
You should read Chapter 12 and understand the difference between these two representations before proceeding.
WARNING: The Chapter 12 I am referring to is Chapter 12 of the Second Edition of the book, which is significantly different from the version we used in CS115 last semester. I will hand out copies of the new Chapter 12 in class.
You have some choices about how to organize the code, but here is what I did: I put both class definitions in one file named Deck.java and made Card a non-public class. Then I moved main into the Deck class.
It is probably a good idea to make this transformation one method at a time, and test the program after each change. On the other hand, if you are confident you know what you are doing, you can make most of the changes with search-and-replace commands.