Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction You will complete one program to give you experience with: Multidimensional Lists Task 1 Create a program that uses the deck and card classes

Introduction

You will complete one program to give you experience with:

  • Multidimensional Lists

Task 1

Create a program that uses the deck and card classes provided. Name your file assn16-task1.py. You will implement the Blackjack game. The goal is to have a higher score than the dealer without going over 21 points. This version does not have all features of regular blackjack. Please read the requirements. It must have only the following features:

  • Prompt the user for the number of players. This does not include 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 their prompt
      • The minimum bet is $5 or their entire balance, whichever is lower
    • Deal the cards
      • Each round will have a fresh deck of shuffled cards
      • Cards are dealt one at a time beginning with player 1 and ending with the dealer
      • Each player (including the dealer) gets two cards, meaning there 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 another card(s) to the dealer
      • The dealer must take a card until its total is 17 or higher
      • If the dealer's initial hand is 17 or higher it does not take a card
      • Use appropriate messages so the players know what the dealer is doing
        • Ex: "The dealer takes a card" / "The dealer busts" / "The dealer holds"
    • Determining winners
      • If the dealer busts (goes over 21), all players who did not bust win
      • If the player and dealer totals are the same they tie
      • If the players hand is lower than the dealer, the player loses
      • Use appropriate messages to let each player know what their result 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 all their money)
  • Ask to Play again
    • Yes: Repeat the round for all players with a positive balance
    • No
      • Print a Thank You message
      • Print each player's name (their player number) and balance starting with the one with the highest. You should perform a sort first.

Notes:

  • This is not quite real blackjack.
    • The player and dealer will not automatically win if they have Blackjack (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 cards exceeds 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 all players and the dealer
  • Use other appropriate list(s) to manage the account balance for each player and wagers
  • Use appropriate prompts so it is clear which player should be playing and what their options are
  • Use appropriate messages so players know what is happening in the game
  • You should not modify the card or deck files

image text in transcribed

image text in transcribed

Rubric

10 pts: Proper menus, prompts, and outputs

14 pts: Multidimensional list to keep track of hands

12 pts: Account balances and bets managed correctly (including cases where a balance is less than $5)

12 pts: Proper logic for calculating hand totals (don't forget Aces and face cards)

12 pts: Proper logic for flow for a single player turn

12 pts: Proper logic for flow for a round for all players (goes from player to player properly, including if a player is out)

12 pts: Dealer turn logic and flow is correct

10 pts: Correct logic to determine winners and payouts

6 pts: Software Development Plan (UML for included files is not required)

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() 1 and self.getcardValue()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is meant by 'Wealth Maximization ' ?

Answered: 1 week ago