Mark's Site Logo

In 11th grade, I took AP Computer Science AB, skipping the A that normally precedes it. At that point, it still used C++. I learned a great deal in that class, which was the equivalent of a college course in data structures. My final project in the class was a blackjack program. I have been told that it's pretty realistic; I modeled the shuffling algorithm loosely on what one does during a real shuffle of a deck - cut the deck a few times, then take the two halves and flip them together. You can download it below and try it out. There is some glitchiness, some of which is due to occasional wackiness with C++ input handling, but it does handle splits, dealer blackjack insurance, and all that sort of thing. Dealer stands on 17.

Download "Mark's Master Blackjack"

I have also posted the source. I did many dirty tricks with implicit boolean conversions and for loops back then; my friend and I would always compete to write shorter programs before we learned better. Fortunately, even then I knew the value of good commenting, so it's not too tough to follow. Although it isn't exposed as an option while playing, the number of decks is a compiler constant—another thing I'm glad my earlier self had the foresight to do. Unfortunately there is another set of hard-coded constants that would have been better-served as an enumeration.

Download "Mark's Master Blackjack" source

It references the AP classes, the source of which is also posted here.

Download source for AP classes

Color scheme: