Chapter 20. Having Some Fun with Blackjack
Over the past few days, you’ve worked on a fairly intense OOP project. Today you get to kick back and have a little fun with the Blackjack game by using polymorphism to add a number of non-human players to the game. You’ll also get to see how OO lends itself to simulators.
Today you will learn how you can
Use polymorphism to add players to the Blackjack game
Use OO to create simulators
Having Fun with Polymorphism
The game of Blackjack allows for up to seven players to play at any given time. Up until now the game that you’ve created has only included a human player and the dealer. Luckily, polymorphism allows you to add non-human players to the game.
Creating a Player
To create a new non-human player, simply ...
Get Sams Teach Yourself Object Oriented Programming in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.