Conversation
nancy-harris
left a comment
There was a problem hiding this comment.
Excellent job! There are comments below about how to better use parent classes. Please be sure to read that. For commits, it would be good if your commits were more descriptive. Instead of writing about which wave you completed, consider messages like "Created Item class" or "Added swap_items function to Vendor class".
| pass No newline at end of file | ||
| from swap_meet.item import Item | ||
|
|
||
| class Clothing(Item): |
There was a problem hiding this comment.
Great start on adding Item as the parent class for Clothing! However, you are not fully using all of the things that parent classes offer. Rather than setting category and condition in the child class, you can send those values to the super class and it can be set there for you. You would use this line of code:
super().__init__("Clothing", condition)
and then you could remove lines 7 and 8. This works for Decor and Electronics as well!
| if category is None: | ||
| category = "" |
There was a problem hiding this comment.
You do not need to use None if the field is a string! Strings are immutable, so you can have the default be "". You want to use None for things that are mutable, like lists or dictionaries.
| ''' | ||
| if self.condition <= 1: | ||
| return "Uhhh" | ||
| elif self.condition <= 2 and self.condition >= 1: |
There was a problem hiding this comment.
Since you use elif, you can make your statements cleaner. For instance, you don't need to use >= 1 here because you know in order to get here the condition has to be higher than 1 because it skipped the first if.
| # default value None is IMMUTABLE. MUTABLE type should not be used in DEFAULT argument. | ||
|
|
||
| # Wave 1 | ||
| def __init__(self, inventory = None): |
| inventory = [] | ||
| self.inventory = inventory | ||
|
|
||
| def add(self, add_item): |
| assert item_a not in items | ||
| assert item_b not in items | ||
| assert item_c not in items No newline at end of file |
There was a problem hiding this comment.
Great asserts! These three are actually not needed. Since the first assert tells us that there is nothing in the list, we don't need to check if these individual items are in the list.
| assert result == True | ||
| assert len(tai.inventory) == 3 | ||
| assert len(jesse.inventory) == 3 | ||
| assert item_a in tai.inventory | ||
| assert item_b in tai.inventory | ||
| assert item_c in jesse.inventory | ||
| assert item_f in tai.inventory | ||
| assert item_d in jesse.inventory | ||
| assert item_e in jesse.inventory |
| assert result == True | ||
| assert len(tai.inventory) == 3 | ||
| assert len(jesse.inventory) == 3 | ||
| assert item_a in tai.inventory | ||
| assert item_b in tai.inventory | ||
| assert item_f in tai.inventory | ||
| assert item_d in jesse.inventory | ||
| assert item_e in jesse.inventory | ||
| assert item_c in jesse.inventory |
| assert not result | ||
| assert len(tai.inventory) == 3 | ||
| assert len(jesse.inventory) == 3 | ||
| assert item_a in tai.inventory | ||
| assert item_b in tai.inventory | ||
| assert item_c in tai.inventory | ||
| assert item_d in jesse.inventory | ||
| assert item_e in jesse.inventory | ||
| assert item_f in jesse.inventory |
| assert not result | ||
| assert len(tai.inventory) == 3 | ||
| assert len(jesse.inventory) == 3 | ||
| assert item_a in tai.inventory | ||
| assert item_b in tai.inventory | ||
| assert item_c in tai.inventory | ||
| assert item_d in jesse.inventory | ||
| assert item_e in jesse.inventory | ||
| assert item_f in jesse.inventory |
No description provided.