Isaac H.
asked 12/21/22Write the definition of a class named "Card" which creates a card from a standard deck of cards.
Write the definition of a class named "Card" which creates a card from a standard deck of cards. This class should have the following methods: __init__(self, rank, suit), getRank(self), getSuit(self), printCard(self), shuffle(self), and cheat(self, rank, suit).
• The suits are: "Hearts", "Diamonds", "Clubs", and "Spades".
• The ranks are: "Ace", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", and "King".
• getRank(self) and getSuit(self) return the rank and the suit of the card, respectively.
• printCard(self) prints the information on the card, like "This card is the Ace of Spades."
• shuffle(self) replaces the card with any card from the deck, chosen randomly.
• cheat(self, rank, suit) changes the rank and suit of the card to the input given in cheat.
The user should be able to do the following (also see template below):
c = Card("Ace", "Spade")
c.getRank()
"Ace"
c.getSuit()
"Spade"
c.printCard()
This card is the Ace of Spades.
c.shuffle()
c.printCard()
This card is the Ten of Diamonds. # Or any other random card
c.cheat("King", "Heart")
c.printCard()
This card is the King of Hearts.
c.cheat("12", "Spades")
c.printCard()
Invalid card
2 Answers By Expert Tutors
William M. answered 01/07/23
Computer/HS Instructor w/7+ years teaching Computer Science
Kevin S. answered 12/25/22
Experienced Computer Science Tutor: 20 Years Experience
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Michael M.
This isn't a question so much as it's a request for someone to either help with your assignment or to do your assignment for you. I would recommend hiring a tutor to assist with this, as it's not something that can be answered in a simple response (without literally doing your assignment for you).12/23/22