Sea Turtles - Heather M. - #14
Conversation
tgoslee
left a comment
There was a problem hiding this comment.
Heather this was a great approach to the swap meet project! Your code was clean, efficient, and readable. I left a few comments on things you did great and things you can refactor. Let me know if you have any questions.
| pass No newline at end of file | ||
| from swap_meet.item import Item | ||
|
|
||
| class Clothing(Item): |
| pass No newline at end of file | ||
| from swap_meet.item import Item | ||
|
|
||
| class Decor(Item): |
| pass | ||
| from swap_meet.item import Item | ||
|
|
||
| class Electronics(Item): |
| CATEGORIES = { | ||
| "": "Hello World!", | ||
| "Clothing": "The finest clothing you could wear.", | ||
| "Decor": "Something to decorate your space.", | ||
| "Electronics": "A gadget full of buttons and secrets.", | ||
| } | ||
|
|
||
| CONDITION_DESCRIPTORS = { | ||
| 0: "Oof. Are you sure you want this?", | ||
| 1: "Wow. It's pretty bad.", | ||
| 2: "Significant damage.", | ||
| 3: "Needs some love.", | ||
| 4: "Minor signs of wear or damage.", | ||
| 5: "So good it might be a scam.", | ||
| } |
There was a problem hiding this comment.
Heather great job making these global "constant" variables. This helps eliminate redundant code blocks and makes this accessible to other subclasses.
| def __init__(self, category = "", condition = 0): | ||
| self.category = category | ||
| self.condition = condition | ||
|
|
||
| def __str__(self): | ||
| return CATEGORIES[self.category] | ||
|
|
||
| def condition_description(self): | ||
| return CONDITION_DESCRIPTORS[int(self.condition)] No newline at end of file |
| swap_items = self.inventory[my_item_index], vendor.inventory[their_item_index] | ||
| vendor.inventory[their_item_index], self.inventory[my_item_index] = swap_items |
There was a problem hiding this comment.
Great job on this streamlined approach. The add and remove methods are now just taking up space. I understand that you technically need them to pass the tests but just wanted to make that note.
| try: | ||
| my_item = self.inventory[0] | ||
| their_item = vendor.inventory[0] | ||
| self.swap_items(vendor, my_item, their_item) |
There was a problem hiding this comment.
great use of your previously created method.
| except: | ||
| return False | ||
|
|
||
| def get_best_by_category(self, category): |
| my_item = self.get_best_by_category(their_priority) | ||
| their_item = other.get_best_by_category(my_priority) |
No description provided.