1. class.py
class Card: deckCounter = 0 def __init__(self, title, suit): self.title = title self.suit = suit Card.deckCounter += 1 def flipCard(self): print(self.title, "of", self.suit) card1 = Card("Ace", "Spades") card2 = Card("Seven", "Diamonds") card1.flipCard() card2.flipCard() print(Card.deckCounter, "cards in deck")
#Joker overrides parent class methods: class Card: deckCounter = 0 def __init__(self, title, suit): self.title = title self.suit = suit Card.deckCounter += 1 def flipCard(self): print(self.title, "of", self.suit) class Joker(Card): def __init__(self): Card.deckCounter += 1 def flipCard(self): print("Joker") card1 = Card("Ace", "Spades") card2 = Card("Seven", "Diamonds") card3 = Joker() card1.flipCard() card2.flipCard() card3.flipCard() print(Card.deckCounter, "cards in deck")