Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1: Card class Create a Python file called pfoyingCords.py. Inside this le, create and test a Card class according to the description below. Note

image text in transcribed
Task 1: Card class Create a Python file called pfoyingCords.py. Inside this le, create and test a Card class according to the description below. Note that the following methods form the public interface for this class you must complete them all as specified, and cannot add additional methods to the public interface. However, you can include additional private helper methods that are m called within this class, if you wish. Card. (rank, suit, faceUp} creates a card which is described by its rank and suit, that is either facing up (so that the rank and suit are visible] or facing down [so that only the back of the card can be seen}. The _inic method should assert that the values of the input parameters are valid, before being used to initialize three private attributes of the same names {i.e. self . _rank, self . suit, self . faceUp]. Avalid rank is one of the following onecharacterstrings: 'A', 'a', '2', '3', '4', '5', '5', 'T', '8', '9', 'T', 't', 'J', 'j', '(1', 'q', 'K', 'k' and a valid suit is one ofthe following one character strings: '5', 's', 'H', 'h', 'D', 'd', 'C', 'c'; but self._rank and self.suit should be uppercase if it is a letter. A valid faceUp is Boolean, where a True value indicates that the card is facing up and a False value indicates that the card is facing down. getRank f} returns the rank of the Card instance as a one-character string. getSuit f} returns the suit of the Card instance as a onecharacter string. iSFaceUp [l returns the Boolean value indicating whether the Card instance is facing up [True] or down {False}. turnOver [) updates the Card instance so that if it was facing up, it will now be facing down. Similarly, if it was facing down, it will not be facing up. Nothing is returned. eq (anotherCard) checks to see if the Ca rd instance and anotherCard are the same (i.e. both rank and suit]. Returns a Boolean value. Note that this is a special method, and will be called when the equivalency operator [==;I is used between two Card objects. str :1) returns the string representation of the Card instance. For example, a ten of hearts which is facing up will return the string ' [ TH ] ', with a single space between the open square bracket and the rank, and a single space after the suit. Any card that is facing down will return the string

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions