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:CardDeck andHand Each class should be implemented in its own Python file. Two example main programs, each using the three classes, are given see attachedmainpyandmainpy
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 points
pointsinit: An initializer with the parametersrankeither astringor aninteger andsuita character You can use thetypefunction to check the type of the parameter. You can assume that the constructor for Card is always invoked with valid parameter values.
points The Card class has twopublicinstance variables:rankandsuit The rank is stored as an integer in the range The suit is stored as a character: HSD or C for hearts, spades, diamonds, and clubs, respectively.
pointsstr: 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 JQK and A are used for ranks and respectively. For example, the string representation for the of hearts and ace of spades isHand AS respectively.
Deck class points
pointsinit: An initializer without any parameters, which creates a deck of cards. The deck is constructed in such a way that the cards are first ordered by their suit,HSDChearts first, then spades, diamonds, and clubs and then by their rank in ascending order. The first three cards in a deck are therefore: HH and H
points The Deck class has onepublicinstance variable,deck which contains a list of cards in each of the four suits, that is a total of cards.
pointsstr: 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 cards.
pointsshuffle: Shuffles the cards in the deck usingrandomshuffle Note, you shouldnotcallrandomseedwithin the class.
pointsdeal: 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 points
pointsinit: An initializer without any parameters.
points The Hand class has onepublicinstance variable,cards for storing alistof up to cards. Additionally, you must have the required constants, as can be seen from the attached programs.
pointsstr: 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.
pointsaddcardcard: 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 constantNUMBEROFCARDSin the Hand class.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
