Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Programming, Testfile not needed Instructions You will need to create three files: . Card.py - Defines a Card class. For simplicity, this class will

Python Programming, Testfile not neededimage 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 BST 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 / 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: . suit - string value that distinguishes what suit that card is: C (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, 6, 7, 8, 9, 10, J (Jack), Q (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 BST, None if it has no left child right - a reference to the right child of a card in the BST, 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. . __init__(self, suit, rank) Your Card class definition should also support the following "getter" and "setter" methods: . . . . . getSuit(self) setSuit(self, suit) getRank(self) setRank(self, rank) getCount (self) setCount (self, count) getParent(self) setParent (self, parent) getLeft (self) setLeft (self, left) getRight (self) setRight (self, right) _str_(self) - the overloaded to-string operator. For example, it should return the string 'S A | 1 " if the Card is an Ace of Spades and has no duplicates . . Lastly, your Card class can overload the >, s, and == operators. This is optional, but it can be helpful when inserting cards into their proper position within the PlayerHand BST. In this context, a Card should first be compared by its rank. For our purposes, we treat A (Ace) as the smallest, and K (King) as the largest. If the rank is equal, we then compare the suit of the cards, where C (Club) , s, and == operators. This is optional, but it can be helpful when inserting cards into their proper position within the PlayerHand BST. In this context, a Card should first be compared by its rank. For our purposes, we treat A (Ace) as the smallest, and K (King) as the largest. If the rank is equal, we then compare the suit of the cards, where C (Club)

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

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago