''' DS2000 Spring 2023 Sample code from class - the Deck What attributes (variables) - what does it HAVE? * list of cards * size? (design choice) What methods (functions) - what does it DO? * shuffle * deal a card * cut the deck? ''' import random from card import Card SUITS = {1 : "clubs", 2 : "diamonds", 3 : "hearts", 4 : "spades"} class Deck: ''' Deck class attributes: list of card objects init method: creates the list of 52 cards, with values 2-14 and suits clubs/diamonds/hearts/spades methods: shuffle the deck, deal one card ''' def __init__(self): self.cards = [] for i in range(2, 15): for key, value in SUITS.items(): c = Card(value = i, suit = value) self.cards.append(c) def shuffle(self): for i in range(len(self.cards)): r = random.randint(0, len(self.cards) - 1) self.cards[i], self.cards[r] = self.cards[r], self.cards[i] def deal(self): return self.cards.pop()