Blackjack ( Due 14 Feb 2014 )

In this program you will use the following classes - Card, Deck, Player, Dealer, and Blackjack. The intent of this assignment is for you to simulate a Blackjack game using classes and object-oriented programming similar to your last programming assignment. This program will introduce the concept of inheritance.

class Card (object):

class Deck (object):

class Player (object):

class Dealer (Player):

class Blackjack (object):

def main():


In Blackjack you want to have a hand value that is closer to 21 than that of the dealer, without going over 21. You are playing strictly against the dealer and not against the other players at the table. The values of the cards are as follows:

The value of a hand is simply the sum of the point counts of each card. If the first two cards in your hand is (Ace, 8) and stop there, then Ace will count as 11 and your hand is worth 19 points. If, on the other hand, you get another card and it is another 8, you now have (Ace, 8, 8) and in this case Ace is 1 and your hand is worth 17 points.

The dealer deals two cards to all the players including himself. The players' cards are dealt face up. Only one of the cards of the dealer is face up and the other is face down.

Once the cards are dealt, each player in turn indicates to the dealer how he wishes to play his hand. After each player has finished, the dealer will complete his hand. In a casino the dealer will either pay or collect the players' bets. In your program you will write out whether the players won or lost or tied with the dealer.

The dealer has no choice in how he plays his hand. He must continue to take cards ("hit") until his total is 17 or greater. An Ace in the dealer's hand is always counted as 11 if possible without the dealer going over 21. So if the dealer has (Ace, 9), then his total will be 20 and he stops drawing cards ("stand"). However, if the dealer had (5, 7) and then added an Ace and his hand was (5, 7, Ace) then the total is 13 and so he hits again. Supposing he now he draws a 5, then is hand (5, 7, Ace, 5) totals 18 and he stands.

In the case of the player we have simplified the options that he has. The player can either hit or stand. Doubling or splitting pairs are not options that you will simulate in your program.

Your program will allow anywhere between 1 and 6 players (inclusive). Here is what your output will look like:

Enter number of players: 2

Player 1: 7S 5D - 12 points
Player 2: 4H JC - 14 points
Dealer: 10D

Player 1, do you want to hit? [y / n]: y
Player 1: 7S 5D 8H - 20 points
Player 1, do you want to hit? [y / n]: n

Player 2, do you want to hit? [y / n]: y
Player 2: 4H JC 9S - 23 points

Dealer: 10D 9C - 19 points

Player 1 wins
Player 2 loses

Here are some special cases to consider. If the Dealer goes over 21, all players who are still standing win. But the players that are not standing have already lost. If the Dealer does not go over 21 but stands on say 19 points then all players having points greater than 19 win. All players having points less than 19 lose. All players having points equal to 19 tie. This last case we made up to simplify your programming.

The file that you will be turning in will be called This is a template of the code. The code is not complete and it was written in part for a single player. I would like you to make modifications to the code so that it follows the specifications. The file will have a header of the following form:



  Student's Name:

  Student's UT EID:

  Course Name: CS 313E 

  Unique Number: 53580

  Date Created:

  Date Last Modified:


Use the turnin program to submit your file. The TAs should receive your work by 11 PM on Friday, 14 Feb 2014. We will be looking for clean logic and good documentation. There will be substantial penalties if you do not adhere to the guidelines. The student assistant in charge of this assignment is Daniel Monroy (