Question: Please I need help with this lab. The due date is March 13. Thank you in advance. Contact me if any questions about it. Introduction

Please I need help with this lab. The due date is March 13. Thank you in advance. Contact me if any questions about it.

Please I need help with this lab. The due date is March13. Thank you in advance. Contact me if any questions about it.Introduction The goal for this lab is to write a program thatwill manage cards for a card game. All cards have a suitand a rank, which can be used to determine the value of

Introduction The goal for this lab is to write a program that will manage cards for a card game. All cards have a suit and a rank, which can be used to determine the value of cards in relation to each other. All cards will be managed by a Binary Search Tree (BST) where the best card is the maximum and the worst card is the minimum. In order to manage cards for this lab, you will define a Card and PlayerHand classes that organizes the cards in a BST data structure. You will also write pytests in testFile. py illustrating your behavior works correctly. This lab writeup will provide some test cases for clarity, but the Gradescope autograder will run different tests shown here. 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)0 rank - string value to distinguish the rank of the card {in ascending value): A (ace). 2, 3, 4, 5, 5. T, E, 9, J (Jacki. El {Queen}, K {King}. Assume there is no Joker I parent - a reference to the parent node of a card in the EST, None if it has no parent {aka, it is the root] I left - a reference to the left child of a card in the EST, None if it has no left child I right a reference to the right child of a card in the BST. None if it has no right child I 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 Ca rd object by passing in values for the suit and rank. Your constructor should also create the count attribute and initialize it to 0, as well as create the pa rent, left, and right attributes initialized to None I _init_(se1f, suit, rank] Your Card class denition should also support the following \"getter" and "setter" methods: I getSuitiselfi I setSuitiself, suit) I getRankiself) I setRankiself, rank} I getteuntiself) I settountiself, count] I getParentiselfi I setParentlself, parent} I getLeftiself) I setLeftiself. left} I getRightiself) I setRightiself, right] I _str_isei.fi the overloaded tostring operator For example, it should return the string "5 A | 1" if the Ca rd is an Ace of Spades and has no duplicates Lastly, your Card class can overload the a, c, and = operators. This is optional, but it can be helpful when inserting cards into their proper position within the PtayerHand BST. In this context. a Card should first be compared by its rank. For our purposes, we treat it (Ace) as the smallest. and K {King} as the largest. If the ranl-t is equal, we then compare the suit of the cards, where C {Club}

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!