(upbeat music)
- [Instructor] This challenge represents a final project
for the course.
For this project, you will create a class
for a deck of cards.
A standard deck of playing cards includes 52 cards,
there are four suits, spades, hearts, diamonds and clubs.
And within each suit there are 13 ranks.
Ace, two, or deuce, three or tres,
4 5 6 7 8 9 10,
jack, queen, and king.
For our purposes, the ace is represented by the letter A,
the 10 by the letter T
This allows it to fit in the space of one character,
the jack, queen and king by letters J, Q and K
and the numerics, two, three nine
by their respective digits.
The suits are represented by their letters,
S for spades, H for hearts, D for diamonds,
and C for clubs.
So these cards are the 10 of spades,
the three of hearts,
the king of diamonds,
and the six of clubs.
For this exercise, you may choose to use the STL or not
at your own discretion.
The STL may make the exercise easier for you.
For my part, I chose not to use it because I wrote my class
with a mobile application in mind,
so I wanted to keep it as lean and efficient as possible.
The choice to use the STL or not is up to you.
Your class should hold one or more decks of 52 cards
per deck.
I chose to limit my class to 10 decks maximum,
this should accommodate most potential applications.
You will need a function for shuffling the cards
for this purpose, you'll need a random number generator,
I used the built in random function
seeded with the current time.
You'll need a function that deals a single card
from the deck.
This function will return the next card from the deck
and reduce the count of remaining cards in the deck by one.
You'll need a function that creates a new deck,
which may optionally contain more than one deck of 52 cards.
You may also want utility functions for reporting the number
of cards remaining in the deck,
reporting the size of the deck
and returning a pointer to the array of cards.
These are the parameters for the final project
for this course.
Expect this to take at least a few hours.
Take your time, experiment a lot
and try to gain from the experience.
I'll show you my solution in the rest of this chapter.