import random
class Card:
def __init__(self, rank, suit):
# Initialize the rank and suit of the card
self.rank = rank
self.suit = suit
def getRank(self):
# Return the rank of the card
return self.rank
def getSuit(self):
# Return the suit of the card
return self.suit
def printCard(self):
# Print the information on the card
print(f"This card is the {self.rank} of {self.suit}.")
def shuffle(self):
# Define a list of possible ranks and suits
ranks = ["Ace", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"]
suits = ["Hearts", "Diamonds", "Clubs", "Spades"]
# Assign a random rank and suit to the card
self.rank = random.choice(ranks)
self.suit = random.choice(suits)
def cheat(self, rank, suit):
# Change the rank and suit of the card to the input given in cheat
self.rank = rank
self.suit = suit
# Example usage:
card = Card("Ace", "Spades")
card.printCard() # Output: This card is the Ace of Spades.
card.shuffle()
card.printCard() # Output: This card is the random rank and suit.
card.cheat("King", "Hearts")
card.printCard() # Output: This card is the King of Hearts.