Swap_meet_Daria_Iakymenko_C17(Whales)#92
Conversation
ethod, passed tests for wave5
jericahuang
left a comment
There was a problem hiding this comment.
Phenomenal work on this project, Daria! You demonstrated mastery of Unit 1 concepts and did fantastic with the optional enhancements. 👍🏻 Great code style and very well done on completing the tests. Your project is green 🟢 !
| class Clothing(Item): | ||
|
|
||
| def __init__(self, condition = 0, age = 0): | ||
| super().__init__("Clothing", condition, age) |
There was a problem hiding this comment.
Wonderful! Taking advantage of inheritance by using the parent class's constructor makes this concise!
| other_index = vendor.inventory.index(their_item) | ||
| self_index = self.inventory.index(my_item) | ||
| temp_item = my_item | ||
| self.inventory[self_index] = their_item | ||
| vendor.inventory[other_index] = temp_item |
There was a problem hiding this comment.
Very nice implementation to literally swap by the items' index values! Another approach is using .append() and .remove() but your implementation is just as good!
|
|
||
| def swap_first_item(self, vendor): | ||
| if self.inventory and vendor.inventory: | ||
| return self.swap_items(vendor, self.inventory[0], vendor.inventory[0]) |
There was a problem hiding this comment.
Very nice! Takes advantage of .swap_items() return value and guard clause will prevent an IndexError 👍🏻 Love it!
| def swap_best_by_category(self, other, my_priority, their_priority): | ||
| vendor_best_item = self.get_best_by_category(their_priority) | ||
| other_best_item = other.get_best_by_category(my_priority) | ||
| return self.swap_items(other, vendor_best_item, other_best_item) |
There was a problem hiding this comment.
Nice use of helper functions to make this concise!
| my_newest_item = min(my_category_list, key=lambda x: x.age) | ||
| other_newest_item = min(other_category_list, key=lambda x: x.age) |
There was a problem hiding this comment.
Wonderful use of min() and lambda!
| # ********************************************************************* | ||
| # ****** Complete Assert Portion of this test ********** | ||
| # ********************************************************************* | ||
| assert items == [] #added assert |
| clothing_1 = Clothing(condition=0) | ||
| clothing_2 = Clothing(condition=2) | ||
| decor = Decor(condition=3) | ||
| electronics = Electronics(condition=4) | ||
|
|
||
| assert clothing_1.condition_description() == "Poor" | ||
| assert clothing_2.condition_description() == "So so" | ||
| assert decor.condition_description() == "Quite good" | ||
| assert electronics.condition_description() == "Good" |
| @@ -1,10 +1,11 @@ | |||
| from unicodedata import category | |||
There was a problem hiding this comment.
Not sure what this module is? Did VSCode add it mysteriously?
| assert result | ||
| assert len(jesse.inventory) == len(tai.inventory) | ||
| assert jesse.inventory[0] == item_d | ||
| assert jesse.inventory[1] == item_e | ||
| assert jesse.inventory[2] == item_c | ||
| assert tai.inventory == [item_a, item_b, item_f] |
|
|
||
|
|
||
| #added 2 unit tests to check the 'swap_by_newest' function | ||
| def test_swap_by_newest_item_in_category(): #nominal case |
There was a problem hiding this comment.
Wonderful tests for the optional enhancement!
No description provided.