-
Notifications
You must be signed in to change notification settings - Fork 243
Hand Class
Sar Champagne Bielert edited this page Apr 19, 2024
·
1 revision
Unit 5 Session 1 (Click for link to problem statements)
Understand what the interviewer is asking for by using test cases and questions about the problem.
- How should the
Hand
class behave if trying to remove a card that isn't in the hand?- For this problem, you can assume the card is always in the hand when
remove_card
is called.
- For this problem, you can assume the card is always in the hand when
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Develop a Hand
class to manage a collection of Card
objects, providing methods to add and remove cards.
1) Initialize the `Hand` class with an empty list of cards.
2) Implement `add_card()` to append a `Card` object to the hand.
3) Implement `remove_card()` to remove a `Card` object from the hand.
- Incorrect implementation of the list methods for adding or removing items.
class Hand:
def __init__(self):
self.cards = []
def add_card(self, card):
self.cards.append(card)
def remove_card(self, card):
self.cards.remove(card)