Menu

[Solved]Create Program Uses Deck Card Classes Provided Name File Assn16 Task2py Implement Blackjac Q37212340

Create a program that uses the deck and card classes provided.Name your file assn16-task2.py. You will implement the Blackjackgame. The goal is to have a higher score than the dealer withoutgoing over 21 points. This version does not have all features ofregular blackjack. Please read the requirements. It must have onlythe following features:

  • Prompt the user for the number of players. This does notinclude the dealer. You may have 1 – 5 players
  • Each player starts with $100 in their account
  • A player can continue until they are out of money
  • Each round
    • Prompt each player one at a time for their bet amount.
      • Display the current balance for each user as part of theirprompt
      • The minimum bet is $5 or their entire balance, whichever islower
    • Deal the cards
      • Each round will have a fresh deck of shuffled cards
      • Cards are dealt one at a time beginning with player 1 andending with the dealer
      • Each player (including the dealer) gets two cards, meaningthere will be two cycles of dealing cards to each player.
      • After dealing all cards display the dealer’s second card
    • For each player starting with player 1
      • Show the player hand
      • Ask the player if they’d hit (take another card) or hold
      • Repeat until they hold or bust (total of cards is over 21)
      • If they bust they lose
      • If the player holds then the next player goes
    • After all players are done the dealer complete its turn
      • Display both dealer cards (print each on a new line)
      • Use time.sleep() to wait for 1 second before dealing anothercard(s) to the dealer
      • The dealer must take a card until its total is 17 orhigher
      • If the dealer’s initial hand is 17 or higher it does not take acard
      • Use appropriate messages so the players know what the dealer isdoing
        • Ex: “The dealer takes a card” / “The dealer busts” / “Thedealer holds”
    • Determining winners
      • If the dealer busts (goes over 21), all players who did notbust win
      • If the player and dealer totals are the same they tie
      • If the players hand is lower than the dealer, the playerloses
      • Use appropriate messages to let each player know what theirresult is
    • Player payouts
      • Win – add the amount bet to the player’s balance
      • Tie – neither add nor subtract from he player’s balance
      • Lose – subtract the amount bet from the player’s balance
      • Display each user’s balance (including those who have lost alltheir money)
  • Ask to Play again
    • Yes: Repeat the round for all players with a positivebalance
    • No
      • Print a Thank You message
      • Print each player’s name (their player number) and balancestarting with the one with the highest. You should perform a sortfirst.

Notes:

  • This is not quite real blackjack.
    • The player and dealer will not automatically win if they haveBlackjack (21 on the first hand)
    • There is no doubling down or insurance
  • Card values
    • Numeric cards are worth the same number of points
    • Ace is worth eleven points unless the total of all cardsexceeds 21, then it is counted as one.
    • Jack, Queen, and King are worth 10 points
  • Use the full card name, not the nickname for this task
  • Use a single multidimensional list to manage the hands for allplayers and the dealer
  • Use other appropriate list(s) to manage the account balance foreach player and wagers
  • Use appropriate prompts so it is clear which player should beplaying and what their options are
  • Use appropriate messages so players know what is happening inthe game
  • You should not modify the card or deck files

Given Code:

deck.py

import randomfrom card import Cardclass Deck: def __init__(self): self.shuffle() def shuffle(self): self.__deck = [] for i in range(52): self.__deck.append(Card(i)) random.shuffle(self.__deck) def draw(self): return self.__deck.pop()

card.py

class Card: def __init__(self, value): self.__value = value self.__suits = [“Spades”, “Clubs”, “Hearts”, “Diamonds”] self.__ranks = [“Ace”, “Two”, “Three”, “Four”, “Five”, “Six”, “Seven”, “Eight”, “Nine”, “Ten”, “Jack”, “Queen”, “King”] def getRank(self): return self.__ranks[self.__value % 13] def getSuit(self): return self.__suits[self.__value // 13] def getCardValue(self): return self.__value % 13 + 1 def getDeckValue(self): return self.__value def getNickName(self): nickName = “” if self.getCardValue() > 1 and self.getCardValue() < 11: nickName += str(self.getCardValue()) else: nickName += self.getRank()[0] nickName += self.getSuit()[0] return nickName # Dunder to return a string representation to print() and format() def __str__(self): return self.getRank() + ” of ” + self.getSuit() # Dunder to return a string representation to other usages def __repr__(self): return self.__str__()

Expert Answer


Answer to Create a program that uses the deck and card classes provided. Name your file assn16-task2.py. You will implement the Bl… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *