Conversation
nancy-harris
left a comment
There was a problem hiding this comment.
Great start! You've got a lot of good functionality! I left comments below on some things that would make the code simpler/easier. Since at least one wave is not completed, this project is yellow.
For commits, make sure to commit often! You're off to a good start, but some of the commits could be smaller.
| pass No newline at end of file | ||
| from .item import Item | ||
|
|
||
| class Clothing(Item): |
There was a problem hiding this comment.
Great start on using the Item super class here! However, this doesn't fully take advantage of what super classes can do! You don't need to story category or condition information here, you can pass that up to the Item class. None of the child classes need those lines of code, which will make the code cleaner.
| @@ -1,2 +1,23 @@ | |||
| class Item: | |||
| pass No newline at end of file | |||
| def __init__(self, category = None, condition = 0): | |||
There was a problem hiding this comment.
Category can be set to "" as a default. Strings are immutable in Python, so you don't need to use None. None is for when something is mutable (like a list or a dictionary).
|
|
||
| class Vendor: | ||
| pass No newline at end of file | ||
| def __init__(self, inventory = None): |
| inventory = [] | ||
| self.inventory = inventory | ||
|
|
||
| def add(self, item): |
| self.inventory.append(item) | ||
| return item | ||
|
|
||
| def remove(self, item): |
| return False | ||
|
|
||
| def get_by_category(self, category): | ||
| self.category = category |
There was a problem hiding this comment.
There's no need to set self.category here. Vendors shouldn't have a category!
| self.inventory.remove(my_item) | ||
| vendor.inventory.append(my_item) |
There was a problem hiding this comment.
These would've been good places to use your own add and remove functions that you created earlier.
| vendor.inventory.append(self.inventory[0]) | ||
| self.inventory.remove(self.inventory[0]) | ||
|
|
||
| self.inventory.append(vendor.inventory[0]) | ||
| vendor.inventory.remove(vendor.inventory[0]) |
There was a problem hiding this comment.
Swapping items sounds a lot like what the swap_items function does above. You could simplify this code by calling your own function.
|
|
||
| raise Exception("Complete this test according to comments below.") | ||
| # ********************************************************************* | ||
| assert result == False |
There was a problem hiding this comment.
It would also be good to add an assert to make sure the length of the inventory didn't get changed.
| items = vendor.get_by_category("electronics") | ||
|
|
||
| raise Exception("Complete this test according to comments below.") | ||
| assert len(items) == 0 |
No description provided.