Question: Can I get the code for this problem? # DON'T CHANGE OR REMOVE THIS IMPORT from random import shuffle # DON'T CHANGE OR REMOVE THESE

Can I get the code for this problem?

# DON'T CHANGE OR REMOVE THIS IMPORT from random import shuffle

# DON'T CHANGE OR REMOVE THESE LISTS # The first is a list of all possible card ranks: 2-10, Jack, King, Queen, Ace # The second is a list of all posible card suits: Hearts, Diamonds, Clubs, Spades ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"] suits = ["H", "D", "C", "S"]

# This class represents an individual playing card class Card(): def __init__(self, suit, rank): pass # REMOVE THIS AND REPLACE WITH YOUR CODE

# DON'T CHANGE OR REMOVE THIS # This function creates a string out of a Card for easy printing. def __str__(self): return "[" + self.suit + ", " + self.rank + "]"

# This class represents a deck of playing cards class Deck(): def __init__(self): pass # REMOVE THIS AND REPLACE WITH YOUR CODE # DON'T CHANGE OR REMOVE THIS # This function will shuffle the deck, randomizing the order of the cards # inside the deck. # It takes an integer argument, which determine how many times the deck is # shuffled. def shuffle_deck(self, n = 5): for i in range(n): shuffle(self.cards)

# This function will deal a card from the deck. The card should be removed # from the deck and added to the player's hand. def deal_card(self, player): pass # REMOVE THIS AND REPLACE WITH YOUR CODE

# DON"T CHANGE OR REMOVE THIS # This function constructs a string out of a Deck for easy printing. def __str__(self): res = "[" + str(self.cards[0]) for i in range(1, len(self.cards)): res += ", " + str(self.cards[i]) res += "]" return res

# This class represents a player in a game of Blackjack class Player(): def __init__(self, name): pass # REMOVE THIS AND REPLACE WITH YOUR CODE

def value(self): pass # REMOVE THIS AND REPLACE WITH YOUR CODE

def choose_play(self): pass # REMOVE THIS AND REPLACE WITH YOUR CODE

# DON'T CHANGE OR REMOVE THIS # This function creates a string representing a player for easy printing. def __str__(self): res = "Player: " + self.name + " " res += "\tHand: " + str(self.hand[0]) for i in range(1, len(self.hand)): res += ", " + str(self.hand[i]) res += " " res += "\tValue: " + str(self.value()) return res

# This class represents a game of Blackjack class Blackjack(): def __init__(self, players): pass # REMOVE THIS AND REPLACE WITH YOUR CODE

def play_game(self): pass # REMOVE THIS AND REPLACE WITH YOUR CODE

# DON'T CHANGE OR REMOVE THIS # This function creates a string representing the state of a Blackjack game # for easy printing. def __str__(self): res = "Current Deck: \t" + str(self.deck) res = " " for p in self.players: res += str(p) res += " " return res

# DO NOT DELETE THE FOLLOWING LINES OF CODE! YOU MAY # CHANGE THE FUNCTION CALLS TO TEST YOUR WORK WITH # DIFFERENT INPUT VALUES. if __name__ == "__main__": # Uncomment each section of test code as you finish implementing each class # for this problem. Uncomment means remove the '#' at the front of the line # of code. # Test Code for your Card class #c1 = Card("H", "10") #c2 = Card("C", "A") #c3 = Card("D", "7")

#print(c1) #print(c2) #print(c3)

print()

# Test Code for your Deck class #d1 = Deck() #d1.shuffle_deck(10) #print(d1)

print()

# Test Code for your Player class #p1 = Player("Alice") #p2 = Player("Bob") #d1.deal_card(p1) #d1.deal_card(p2) #print(p1.value()) #print(p2.value()) #d1.deal_card(p1) #d1.deal_card(p2) #print(p1.value()) #print(p2.value()) #d1.deal_card(p1) #d1.deal_card(p2) #print(p1.value()) #print(p2.value()) #print(p1) #print(p2) #print(p1.choose_play()) #print(p2.choose_play())

print()

# Test Code for your Blackjack class #terrible_people = [Player("Summer"), Player("Rick"), Player("Morty"), Player("Jerry")] #game = Blackjack(terrible_people) #print(game) #game.play_game() #print(game)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!