Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

Implementing the Basic Blackjack Game using Python

Implementing the Basic Blackjack Game using Python

Implementing the Basic Blackjack Game using Python

Description

Unformatted Attachment Preview

What’s your name?: Heejun
Heejun was dealt a hand with a value of 11
Would you like to take another card? (Y/N) Y
Heejun was dealt a hand with a value of 14
Would you like to take another card? (Y/N) Y
Dealer BUSTED with a total value of 23!
You have stopped taking more cards with a hand value of 15.
** Heejun, You win! **
Would you like to play again? (Y/N) Y
What’s your name?: Heejun
Heejun was dealt a hand with a value of 18
Would you like to take another card? (Y/N) N
You have stopped taking more cards with a hand value of 18.
The dealer was dealt a hand with a value of 10
** Heejun, You win! **
Would you like to play again? (Y/N) Y
What’s your name?: Heejun
Heejun was dealt a hand with a value of 20
Would you like to take another card? (Y/N) N
You have stopped taking more cards with a hand value of 20.
The dealer was dealt a hand with a value of 11
** Heejun, You win! **
Would you like to play again? (Y/N) Y
What’s your name?: Heejun
Heejun was dealt a hand with a value of 11
Would you like to take another card? (Y/N) Y
Heejun was dealt a hand with a value of 12
Would you like to take another card? (Y/N) Y
You BUSTED with a total value of 22!
You have stopped taking more cards with a hand value of 22.
**Heejun, You lose. **?”””You should not share this solution with anyone.
Please remember that you signed an Academic Honesty Agreement.”””
import random
class PlayingCard:
def __init__(self, suit, value):
self.suit = suit
self.value = value
def get_suit(self):
return self.suit
def get_value(self):
return self.value
def get_num_value(self):
if self.value == “ace”:
return 1
elif self.value == “jack”:
return 10
elif self.value == “queen”:
return 10
elif self.value == “king”:
return 10
else:
return self.value
class Deck:
def __init__(self):
self.cards = []
def draw_card(self):
selected_card = random.choice(self.cards)
self.cards.remove(selected_card)
return selected_card
def init_deck(self):
suits = [“hearts”, “diamonds”, “spades”, “clubs”]
values = [“ace”, 2, 3, 4, 5, 6, 7, 8, 9, 10, “jack”, “queen”, “king”]
for suit in suits:
for value in values:
self.cards.append(PlayingCard(suit, value))
class Person:
def __init__(self, deck):
“””set hand and get two initial cards from the deck”””
self.hand = Hand()
self.hand.get_cards(deck)
def play_turn(self, deck):
“””add a card from the deck to hand”””
def report_score(self):
“””report total values of the hand”””
class Dealer(Person):
def __init__(self, deck):
“””inheirt Person Class and set self.name as ‘Dealer'”””
super().__init__(deck)
self.name = “Dealer”
class Player(Person):
def __init__(self, deck, name):
“””inheirt Person Class and set self.name as what a user typed in”””
super().__init__(deck)
self.name = name
class Hand:
def __init__(self):
“””set self.cards as an empty list”””
self.cards = []
def get_cards(self, deck):
“””draw two initial cards from the deck and append them to self.cards”””
self.cards.append(deck.draw_card())
self.cards.append(deck.draw_card())
def get_total_value(self):
“””get total value of cards in the hand”””
## iterate over self.cards and get the total value from self.cards and return it
sum = 0
for card in self.cards:
sum += card.get_num_value()
return sum
def add_card(self, deck):
“””draw one card from the deck and append them to self.cards”””
class BlackjackGame:
def __init__(self):
“””initialize deck and player”””
self.deck = Deck()
self.player = None
self.dealer = None
def play_game(self):
# Prime the loop and start the first game.
user_response = “Y”
while user_response == “Y” or user_response == “y”:
## fill the deck with 52 cards
self.deck.init_deck()
## initialize a player amd dealer and get two cards per player
player_name = input(“What’s your name?: “)
self.player = Player(self.deck, player_name)
self.dealer = Dealer(self.deck)
“””All control should take a place here”””
game = BlackjackGame()
game.play_game()

Purchase answer to see full
attachment
Explanation & Answer:

Worksheet

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20