""" Felix Muzny DS 2000 Lecture 20 November 19, 2024 - Card class (in card.py) - diver/main code (in this file itself) Lecture 20: - add a Deck class - play "whose card is higher" between two players (see lec 19 code for blackjack code) """ # so we can access the Card class without saying card.Card from card import Card from deck import Deck # random for what we're doing in Lec 20 import random NUM_SUITS = 4 MAX_CARD_NUMBER = 13 def make_card(num_suits, max_card_number): """ Randomly make a card from the given suits and numbers, starting at 1 :param num_suits: int :param max_card_number: int :return: a Card object randomly initialized """ return Card(random.randint(1, num_suits), random.randint(1, max_card_number)) def play_compare_cards(card_deck, player1, player2): # draw a card for each player # print the name of the player who wins # or "tie" if it is a tie game card_deck.shuffle() card_p1 = card_deck.draw() print("player 1's card:", card_p1) card_p2 = card_deck.draw() print("player 2's card:", card_p2) # compare the cards # print out the name of the winning player if card_p1 > card_p2: print(player1, "won!") else: print(player2, "won!") # # 7 of diamonds vs. 7 of diamonds # # cards that are literally the same # else: # print("tie!") def main(): # make a deck my_deck = Deck(NUM_SUITS, MAX_CARD_NUMBER) print(my_deck) print() # shuffle the deck my_deck.shuffle() print(my_deck) print() # testing code for draw drawn_card = my_deck.draw() print("drawn card:", drawn_card) print("drawn card:", my_deck.draw()) print("drawn card:", my_deck.draw()) print("drawn card:", my_deck.draw()) print(my_deck) print() play_compare_cards(my_deck, "Felix", "Laney") print(my_deck) main()