Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python: Create a hand of Blackjack BlackjackHand First we will create a class for storing our hand in blackjack, so we can easily figure out

Python: Create a hand of Blackjack

BlackjackHand

First we will create a class for storing our hand in blackjack, so we can easily figure out how much our hand is worth, or display it to the screen.

__init__()

A BlackjackHand doesnt take in any parameters, but it will need to set up a list for storing Cards.

add_card(new_card)

Adds a card to the hand.

parameters

new_card - the Card object to be added to the hand

__str__()

Returns a string representation of the current hand. The resulting string should contain the __str__() value of each card, delimited by commas.

return

A string representing all the cards in the hand. Example: 7 of Diamonds, King of Spades or Ace of Hearts, 8 of Clubs, Queen of Diamonds

get_value()

Returns a numeric point value of the current hand. This should be the sum of the point values of each card. In our implementation of blackjack, an Ace should be either 11 points, or 1, to give the player the highest score without exceeding 21. Hint: First count the total points assuming all aces are 11, along with the number of aces, then decrement point total as the rules allow.

return

A numeric value representing the value of the hand. Examples, respective to the examples in hand_str, above: 17 or 19.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago