BLACKJACK LAB*
Familiarize yourself with the BlackJack project:
ShowDeck().
ShowDeck should use the Display function in the
Card class to display each card in a deck.
Modify the constructor for Dealer so that it calls the
ShowDeck function before and after shuffling the deck to verify
whether the Shuffle function is working.
If you can't see all of your output, you might
put a "pause" in the output by prompting the user to input a character
at the bottom of the ShowDeck function.
You could also display the deck in four columns;
notice that the first row would contain cards 0, 13, 26, and 39,
the second row contains cards 1, 14, 27, and 40, and row i
contains cards ?, ?, ?, and ? (for you to calculate!). How many rows
would you need in your display?
Improve the style of the BlackJack program:
Deck class contains numerous
occurrences of the number 52.
Such use of "magic numbers" is bad programming style
(Quality Tip 2.3 on p. 62).
Get rid of the magic number 52 in the program by introducing a constant
to stand for the number of cards in a standard deck.
Use this constant in the Deck constructor, but in the other
Deck member functions use the vector size function
to determine the number of cards in the deck.
Once we have rid ourselves of this magic number, it should be easier to
make changes to the deck size.
Add a parameter to the Deck constructor indicating how many standard
decks to include in the new deck (1 means a single deck, 2 means a double
deck with 104 cards, 3 a triple deck, etc.).
Be sure to modify the code that constructs the deck as well.
Modify the call to the Deck constructor so that a double deck
is used in the BlackJack game.
Change the implementation of shuffling:
Shuffle to perform a riffle shuffle.
With lots of practice, one can learn to perform a perfect riffle shuffle.
If we start with a fresh deck and perform a perfect riffle shuffle,
we can then predict exactly the arrangement of the deck.
In our example with eight cards, what is the arrangement after three riffle
shuffles? After six?
Modify Shuffle so that it performs the riffle shuffle a
random number of times between 3 and 10.
Print and turn in the header and implementation files for the
Deck and Dealer classes.
Also send e-mail to your lab TA and
include these files as an attachment.
If you have extra time, you can start work on the programming project (due next week at the beginning of lab).
*This lab is based on the lab from Chapter 5 of The Object Concept by Rick Decker and Stuart Hirshfield, International Thomson Publishing Company, 1995.