Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with this python program. Only playerhand.py needed. card.py and bst implementation given to start playerhand.py. Instructions You will need to create three files:

Please help with this python program. Only playerhand.py needed. card.py and bst implementation given to start playerhand.py.

image text in transcribedimage text in transcribedimage text in transcribed
Instructions You will need to create three files: - Card.py - Defines a Card class. For simplicity, this class will assume all Cards have a suit and a rank - PlayerHand.py - Defines a PlayerHand (BST) class that is an ordered collection of a Player's Cards. You can adapt the BET implementation shown in the textbook supporting the specifications in this lab - testFile.py - This file will contain your pytest functions that tests the overall correctness of your class definitions There will be no starter code for this assignment, but rather class descriptions and required methods are defined in the specification below. You should organize your lab work in its own directory. This way all files for a lab are located in a single folder. Also, this will be easy to import various files into your code using the import I from technique shown in lecture. Card.py The Card.py file will contain the definition of a Card class. The Card class will hold information about the cards [suit and rank), and for simplicity, it will also double as a node in our PlayerHand BST. We will define the Card attributes as follows: a suit - string value that distinguishes what suit that card is: (2 (club), D (diamond), H (heart), or S (spade) - rank - string value to distinguish the rank of the card (in ascending value): A (ace), 2, 3, 4, 5, 5, 7, a, 9, 16, J (Jack), 0 (Queen), K (King). Assume there is no Joker - parent - a reference to the parent node of a card in the BST, None if it has no parent (it is the root) - left - a reference to the left child of a card in the EST, None if it has no left child a right - a reference to the right child of a card in the BET, None if it has no right child - count - an integer representing the amount of times this card appears in the BST. 1 by default, but it can be greater since your implementation should support duplicate cards You will write a constructor that allows the user to construct a Card object by passing in values for the suit and rank. Your constructor should also create the count attribute and initialize it to 1, as well as create the parent, left, and right attributes initialized to None. 0 finitilself. suit. rank) Your Card class definition should also support the following "getter" and "setter" methods: 0 getSuitlseLfl - setSuitlself, suit) I getRanklseLfl I setRanklseLf, rank) 0 getCountlself) 0 settountlself. count) - getParentl self} I setParentl self, parent) I getLeftlseL'fl 0 setLeftlseLf. left) 0 getRightlselfi - setRightlself, right) - _st r_(setfl - the overloaded to-string operator. For example, it should return the string "5 A | 1\ " if the Card is an Ace of Spades and has no duplicates Lastly, your Card class can overload the >,

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

Students also viewed these Programming questions

Question

Briefly describe what the CU and ALU of a CPU do

Answered: 1 week ago