Lesson 27 LAB EXERCISE - CARDS

 

Background:

 

A playing card is described using two values, a suit and a value.

 

Four suits:  hearts, clubs, diamonds, spades.

Thirteen values:  two, three, four, five, six, seven, eight, nine, ten, jack, queen, king, ace.

 

 

Assignment:

 

1.   Write a program which supports two new data types, a card suit type and a card value type.  You are encouraged to use these identifiers to name these enumerated types:  suitType and valueType.  The addition of the word Type communicates that these are user-defined types.

 

2.   For each new type, support overloaded input (>>) and output (<<) operators.  Use the background information from the student outline as a template.  When coding your program avoid copying the notes from the student outline.  Study the notes, put them away, then code your answer.

 

3.   The input operator should accept the value or suit of a card in any combination of upper or lower case.  The output of either the value or suit should be done in all lower case letters.

 

4.   Have the program prompt the user for 13 inputs of playing cards.  The run output should consists of 13 lines of output, each one testing a different value of a card.  Vary the input of suits.

 

5.   Here is a sample run output:

 

two of clubs

three of diamonds

four of hearts

five of spades

six of diamonds

seven of hearts

eight of clubs

nine of spades

ten of hearts

jack of diamonds

queen of hearts

king of clubs

ace of spades