Blackjack ( Due 19 Feb 2017 )

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():
...

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.

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 that you will be submitting will be called Blackjack.py. We will be looking for good documentation, descriptive variable names, clean logical structure, and adherence to the coding conventions discussed in class. You may work with a partner on this assignment. Both of you must read the paper on Pair Programming and abide by the ground rules as stated in that paper. The file will have a header of the following form:

  # File: Blackjack.py

  # Description:

  # Student's Name:

  # Student's UT EID:
 
  # Partner's Name:

  # Partner's UT EID: 

  # Course Name: CS 313E 

  # Unique Number: 

  # Date Created:

  # Date Last Modified:

There will be only one copy of the file being submitted if you are doing pair programming.

Use the Canvas system to submit your Blackjack.py file. We should receive your work by 11 PM on Sunday, 19 Feb 2017. There will be substantial penalties if you do not adhere to the guidelines. Remember Python is case sensitive. The name of your file must match exactly what we have specified.