O'Reilly logo

Sams Teach Yourself Object Oriented Programming in 21 Days, Second Edition by Anthony Sintes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required