Conversation
| self.fabric = "Unknown" | ||
|
|
||
| #inherit get_category function from Item class, return class name | ||
| def get_category(self): |
There was a problem hiding this comment.
Since there was no additional functionality in the child's method, you didn't have to reimplement this here. It should automatically call the parent class's version if there isn't anything defined in the child :)
| def __str__(self): | ||
| return super().__str__() + f" It is made from {self.fabric} fabric." | ||
|
|
||
| def condition_description(self): |
There was a problem hiding this comment.
Same comment as above. No need to redefine a child method if it would just use the inherited parent method.
| self.length = length | ||
|
|
||
| #inherit get_category function from superclass Item, return class name | ||
| def get_category(self): |
There was a problem hiding this comment.
Same comment as above. No need to redefine a child method if it would just use the inherited parent method.
| def __str__(self): | ||
| return super().__str__() + f" It takes up a {self.width} by {self.length} sized space." | ||
|
|
||
| def condition_description(self): |
There was a problem hiding this comment.
Same comment as above. No need to redefine a child method if it would just use the inherited parent method.
| self.type = type | ||
|
|
||
| #inherit get_category function from Item class, return class name | ||
| def get_category(self): |
There was a problem hiding this comment.
Same comment as above. No need to redefine a child method if it would just use the inherited parent method.
| def __str__(self): | ||
| return super().__str__() + f" This is a {self.type} device." | ||
|
|
||
| def condition_description(self): |
There was a problem hiding this comment.
Same comment as above. No need to redefine a child method if it would just use the inherited parent method.
| self.inventory.append(add_item) | ||
| return add_item | ||
|
|
||
| #remove duplicates from inventory list if any, else return None |
There was a problem hiding this comment.
I don't know that this comment still matches the function behavior. I don't think it removes duplicates. Rather, it removes an item from the inventory if it existed in the inventory :)
| #swap item between vendors | ||
| def swap_items(self,other_vendor,my_item,their_item): | ||
| if my_item in self.inventory and their_item in other_vendor.inventory: | ||
| self.inventory.remove(my_item) |
There was a problem hiding this comment.
Good use of vendor remove() and append(), instead of just directly appending to the vendor item collection!
| def get_best_by_category(self,category): | ||
| item_list = self.get_by_category(category) | ||
| best_item = None | ||
| temp = 0 |
There was a problem hiding this comment.
for clarity, i would like to see something like cur_best_condition rather than temp, for clarity
| if item.get_category()==category: | ||
| print(str(index) + ". " + item.__str__()) | ||
| index += 1 | ||
| if index == 1: |
There was a problem hiding this comment.
Does this line make sense here? Is there an indentation error?
| return self.swap_items(other_vendor,my_best_item,their_best_item) | ||
|
|
||
| #print out a string that has all the item in the inventory. | ||
| def display_inventory(self,category = ""): |
There was a problem hiding this comment.
I understand what you're doing in this method. However, having the complex if/else statement, which increments the index in different places, isn't so easy for me to read. And I think that maintenance will be more complicated. In this case, I might have three separate blocks of code (like, separate loops), rather than trying to maintain these different possible behaviors within the same enclosing loop.
| return self.swap_items(other_vendor,item,item_to_swap) | ||
| else: | ||
| return self.swap_items(other_vendor,item,item_to_swap) | ||
| print (f"No similiar item in the {item_to_swap.get_category} category. Please try another item.") |
There was a problem hiding this comment.
This line will never execute, as it's after a return in the same block
| assert item_clothing2 in valentina.inventory | ||
|
|
||
| # display inventory as expected after swaps | ||
| #Note: I shift the expected result item 1 and 2. |
There was a problem hiding this comment.
Thank you for adding this comment :)
No description provided.