Skip to content

Swap_meet_Daria_Iakymenko_C17(Whales)#92

Open
diakymenko wants to merge 13 commits intoada-c17:masterfrom
diakymenko:master
Open

Swap_meet_Daria_Iakymenko_C17(Whales)#92
diakymenko wants to merge 13 commits intoada-c17:masterfrom
diakymenko:master

Conversation

@diakymenko
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@jericahuang jericahuang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🟢 !

Comment thread swap_meet/clothing.py
class Clothing(Item):

def __init__(self, condition = 0, age = 0):
super().__init__("Clothing", condition, age)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful! Taking advantage of inheritance by using the parent class's constructor makes this concise!

Comment thread swap_meet/vendor.py
Comment on lines +32 to +36
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread swap_meet/vendor.py

def swap_first_item(self, vendor):
if self.inventory and vendor.inventory:
return self.swap_items(vendor, self.inventory[0], vendor.inventory[0])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Takes advantage of .swap_items() return value and guard clause will prevent an IndexError 👍🏻 Love it!

Comment thread swap_meet/vendor.py
Comment on lines +56 to +59
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of helper functions to make this concise!

Comment thread swap_meet/vendor.py
Comment on lines +71 to +72
my_newest_item = min(my_category_list, key=lambda x: x.age)
other_newest_item = min(other_category_list, key=lambda x: x.age)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful use of min() and lambda!

# *********************************************************************
# ****** Complete Assert Portion of this test **********
# *********************************************************************
assert items == [] #added assert
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

Comment on lines +61 to +69
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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@@ -1,10 +1,11 @@
from unicodedata import category
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this module is? Did VSCode add it mysteriously?

Comment on lines +80 to +85
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]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!



#added 2 unit tests to check the 'swap_by_newest' function
def test_swap_by_newest_item_in_category(): #nominal case
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful tests for the optional enhancement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants