Blackjack

Due: April 30, 11:55pm

Moodle Link
blackjack-01.jpg

Blackjack Game using objects

What is Blackjack?

Blackjack, also known as twenty-one, is the most widely played casino banking game in the world. Blackjack is a comparing card game between a player and dealer, meaning players compete against the dealer but not against other players. It is played with one or more decks of 52 cards. The objective of the game is to beat the dealer in one of the following ways:

  1. Get 21 points on the player's first two cards (called a "blackjack" or "natural"), without a dealer blackjack;
  2. Reach a final score higher than the dealer without exceeding 21; or
  3. Let the dealer draw additional cards until his or her hand exceeds 21.
Here is a link to a small web based version of the game: BlackJack

You are to create a program that plays Blackjack with the computer playing the dealer. The game starts with the dealer drawing two cards and showing only the first, and the player draws two cards, and showing them both. The game then enters a cycle with the playercan choose to either "stand" (stay with the current cards) or hit (get another card). The dealer also continues to hit until he either goes bust (over 21) or stands (when he hit 17 or above). The goal is to either get 21 exactly, or to be the closest to 21 without going over (and thus bust). If the scores are the same, there is a tie, called a "push".

The scoring of card values is as follows. Number cards are worth their face value. Face cards are worth 10. And the ace is either worth 1 or 11, whichever is omre favorable.

You goal is to create a game that plays until someone wins or loses, and then asks if the player wants to play again. Below is some starting code:

You must finish the following classes:

class card:
  def __init__(self,suit,rank):
    "Setup a card given the suit and rank"

  def cardInfo(self):
    " return a string of the card suit and rank"

class deck:
  def __init__(self):
    "Create a new deck of 52 cards"

  def shuffle(self):
    "Shuffle the deck into random order"

  def draw(self):
    "draw a card, removing it from the deck and returning it"

class hand:
    def __init__(self,owner="Player"):
      "create a hand, default to Player"

    def add(self,card):
      "Add a card to the hand"

    def showFirst(self):
      "Print out the first card in the hand"

    def cardList(self):
      "Print ou a list of cards in hand"

    def showHand(self):
      """
      Print the player (Player or Dealer)
      followed by a card list
      followed by the tally
      """

    def tally(self):
        "total the value of the cards in this hand"

Sample Output

See above.

Your function should include calls to input to get the user's guess.

Grading

RequirementPointsCommentsScore
Meets all requirements 70
Code is broken up into functions, with one specific task per function 10
Each function is commented at top of function, after the function name 10
Program has meaningful comments, good variable names, and good formatting 10
Total
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2019-03-24 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback