Conversation
jbieniosek
left a comment
There was a problem hiding this comment.
Good work on this project Carmen! There's some great code in here, and it's very clean and easy to read. Great use of helper methods in the Vendor class!
This project is yellow due to missing inheritance. One of the primary goals of this project was to practice writing classes that use inheritance, and there isn't any in Clothing, Decor or Electronics classes. I also noticed that you were not able to finish the project. I think we should talk about some additional supports at our next 1:1, including possibly some reduced requirements or extended deadlines to see what you might find helpful.
swap_meet/clothing.py
Outdated
| @@ -1,2 +1,10 @@ | |||
| from swap_meet.item import Item | |||
|
|
|||
| class Clothing: | |||
There was a problem hiding this comment.
| class Clothing: | |
| class Clothing(Item): |
swap_meet/clothing.py
Outdated
| def __init__(self, condition = 0): | ||
| self.category = "Clothing" | ||
| self.condition = condition | ||
| self.condition_description = 4 |
There was a problem hiding this comment.
Clothing should be a subclass of Item. If Clothing is a subclass of Item, it would have access to the condition_description function in Item. It could also use the parent class __init__ function to simplify the code here:
| def __init__(self, condition = 0): | |
| self.category = "Clothing" | |
| self.condition = condition | |
| self.condition_description = 4 | |
| def __init__(self, condition = 0): | |
| super().__init__("Clothing", condition) |
swap_meet/item.py
Outdated
| return f"Hello World!" | ||
|
|
||
| def condition_description(self, condition): | ||
| for clothes in range(0, 6): |
There was a problem hiding this comment.
This loop isn't needed. The clothes variable isn't used inside the loop, and the conditionals will result in returning on the first iteration.
swap_meet/item.py
Outdated
| elif condition == 4: | ||
| return "One light scratch" | ||
| else: | ||
| return "Best condition ever" No newline at end of file |
There was a problem hiding this comment.
Conditions can be a float, but this set of conditionals will only work for whole numbers. If an item has a condition of 3.5, this function will return "Best condition ever". How could you adapt these conditionals to work for floats?
| if inventory is None: | ||
| inventory = [] | ||
| self.inventory = inventory |
| friend_list.remove(their_item) | ||
| friend_list.add(my_item) | ||
| self.add(their_item) | ||
| self.remove(my_item) |
| if my_item in self.inventory: | ||
| if their_item in friend_list.inventory: |
There was a problem hiding this comment.
Chained conditionals like this can be combined with and:
| if my_item in self.inventory: | |
| if their_item in friend_list.inventory: | |
| if my_item in self.inventory and their_item in friend_list.inventory: |
| if len(self.inventory) !=0: | ||
| if len(friend_list.inventory) !=0: |
There was a problem hiding this comment.
| if len(self.inventory) !=0: | |
| if len(friend_list.inventory) !=0: | |
| if len(self.inventory) !=0 and len(friend_list.inventory) !=0: |
| def swap_first_item(self, friend_list): | ||
| if len(self.inventory) !=0: | ||
| if len(friend_list.inventory) !=0: | ||
| self.swap_items(friend_list,self.inventory[0], friend_list.inventory[0]) |
|
|
||
| raise Exception("Complete this test according to comments below.") | ||
| #raise Exception("Complete this test according to comments below.") | ||
| assert result == False |
There was a problem hiding this comment.
I suggest adding a check to verify that the inventory wasn't changed by the remove action:
| assert result == False | |
| assert result == False | |
| assert len(vendor.inventory) == 3 |
No description provided.