Lab07

CS 215 Spring 2012 Lab 07 "Objects: Design and Implementation"

Due Lab Day (Tuesday 07/03 (Next week)) submitted before midnight Electronic submission to the CS portal: http://www.cs.uky.edu/csportal

For this week’s laboratory you will be using the techniques covered in the recent lectures to analyze a simple problem and use object-oriented design techniques to create a set of class structures that will aid you in developing a software solution to that problem.
 * Goals and Objectives**

Design and create the interface and implementation files for a class called PlayingCard.
 * Exercise 1 – Playing Card class**

First, you will decide on the data members that will make up an instance of the PlayingCard class by asking these questions:

What is the “value” of a PlayingCard object? What makes up a PlayingCard ? How can I represent this value using previously defined data types?

Next, you will decide on the set of operations that can be performed by/on an instance of PlayingCard class. You will create a member function for each one of these operations that your design requires.

What data is needed to construct a valid instance of PlayingCard ? Can I create an instance of PlayingCard with a default value? If so what value? Can I modify the value of a PlayingCard object? If so, what member functions are needed (set, increment/decrement, etc.)? Do I require methods for PlayingCard comparisons (equals, greater than, less than)? Do I require translations of PlayingCard objects into other types (i.e. a text string)? What other functions are required?

After completing these set of questions your interface file should be completely designed and code.

Now, you will need to complete your implementation file for the class. For each member function you declared in your implementation you will need to implement an algorithm for that function.

Create a small test program that will instantiate five PlayingCard objects with different values and display the values of those objects in a meaningful way (i.e. Ace of Spades);
 * Exercise 2 – Test** ** PlayingCard ** **class**


 * Exercise 3 – The** ** CardDeck ** **class**

Design and create the interface and implementation files for a class called CardDeck. This class will be a collection of PlayingCard objects. Like you did for the PlayingCard class, you will need to go through a similar sequence of questions.

Note: There are various constructions of a deck of playing cards: your standard 52 card deck with 2 through Ace of each suit, a Euchre deck with 24 cards (9 through Ace of each suit), and a Pinochle deck with 48 cards (two Euchre decks) as examples. How can you represent these variations in the CardDeck class?

Create a small test program (a "driver") that will create a deck of cards, put those cards in a random order and display the values of the first five cards.
 * Exercise 4 – Test** ** CardDeck ** **class**

Using the examples in this lab assignment, where would inheritance be used and where would composition be used?
 * Exercise 5 - Questions**