Question: Python3 In many card games, cards are either face up or face down. Add a new instance variable named faceup to the Cardclass to track

Python3

In many card games, cards are either face up or face down. Add a new instance variable named faceup to the Cardclass to track this attribute of a card. Its default value isFalse. Then add a turnmethod to turn the card over. This method resets the faceup variable to its logical negation.

card class I have already:

class Card(object): """ A card object with a suit and rank."""

RANKS = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)

SUITS = ('Spades', 'Diamonds', 'Hearts', 'Clubs')

def __init__(self, rank, suit): """Creates a card with the given rank and suit.""" self.rank = rank self.suit = suit def __str__(self): """Returns the string representation of a card.""" if self.rank == 1: rank = 'Ace' elif self.rank == 11: rank = 'Jack' elif self.rank == 12: rank = 'Queen' elif self.rank == 13: rank = 'King' else: rank = self.rank return str(rank) + ' of ' + self.suit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!