Question: Problem A Cards Languagesenis In this project, you need to implement three classes: Card , Deck , and Hand . Each class should be implemented

Problem A
Cards
Languagesenis
In this project, you need to implement three classes:Card,Deck, andHand. Each class should be implemented in its own Python file. Two example main programs, each using the three classes, are given (see attachedmain1.pyandmain2.py).
Note that some of the other items depend on both passing the tests for class and instance variables as well as implementing the initializer correctly.
Card class (30 points)
(10 points)__init__(): An initializer with the parametersrank(either astringor aninteger) andsuit(a character). You can use thetype()function to check the type of the parameter. You can assume that the constructor for Card is always invoked with valid parameter values.
(10 points) The Card class has twopublicinstance variables:rankandsuit. The rank is stored as an integer in the range 214. The suit is stored as a character: H,S,D, or C, for hearts, spades, diamonds, and clubs, respectively.
(10 points)__str__(): The string representation for an instance of a Card is a right justified field of three characters: the rank followed by the suit. The letters J,Q,K, and A, are used for ranks 11,12,13, and 14, respectively. For example, the string representation for the 10 of hearts and ace of spades is"10H"and" AS", respectively.
Deck class (40 points)
(4 points)__init__(): An initializer without any parameters, which creates a deck of 52 cards. The deck is constructed in such a way that the cards are first ordered by their suit,HSDC(hearts first, then spades, diamonds, and clubs), and then by their rank in ascending order. The first three cards in a deck are therefore: 2H,3H, and 4H.
(9 points) The Deck class has onepublicinstance variable,deck, which contains a list of 13 cards in each of the four suits, that is a total of 52 cards.
(9 points)__str__(): The string representation for an instance of a Deck lists all the cards in the deck in the order they appear (with a single space after each card), breaking into a new line after each 13 cards.
(9 points)shuffle(): Shuffles the cards in the deck usingrandom.shuffle(). Note, you shouldnotcallrandom.seedwithin the class.
(9 points)deal(): Deals a single card from the deck by returning the card removed from the top of the deck (the first card). You may assume this is never called when the deck is empty.
Hand class (30 points)
(6 points)__init__(): An initializer without any parameters.
(8 points) The Hand class has onepublicinstance variable,cards, for storing alistof up to 13 cards. Additionally, you must have the required constants, as can be seen from the attached programs.
(8 points)__str__(): The string representation for an instance of aHandconsists of single line containing the strings representation of each card (with a single space after each card). If the hand is empty, the string Empty is returned.
(8 points)add_card(card): Adds the given card to the hand. If the hand is full, then nothing happens.
Constants
You should use constants in your implentation. You need to figure out which constants to use, but as can be seen in the two main programs, you need at least the constantNUMBER_OF_CARDSin the Hand class.

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 Programming Questions!