Skip to content

Submission project_swap_meet by Sorida Lac C17#88

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

Submission project_swap_meet by Sorida Lac C17#88
soridalac wants to merge 13 commits intoada-c17:masterfrom
soridalac:master

Conversation

@soridalac
Copy link
Copy Markdown

Thank you for taking time to review my codes and give feedbacks :)

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.

Fantastic work on this project, Sorida! The code you wrote passed all the tests and met the learning goals. You had wonderful code style and great comments throughout. Your project is green 🟢 ! Congrats on completing Unit 1!

Comment thread swap_meet/item.py
return "Hello World!"

def condition_description(self):
CONDITIONS = {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lovely use of a constants dictionary to log the condition numbers to their descriptions!

Comment thread swap_meet/vendor.py
if not self.get_by_category(category):
return None
# Return the item that are match category and highest condition even there's duplicate items
return max(self.get_by_category(category), key=attrgetter("condition"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fantastic use of max() with key!

Comment thread swap_meet/vendor.py
their_best_item = other.get_best_by_category(my_priority)

# Return swap best items between Vendor and Vendor friend's from inventory
return self.swap_items(other, my_best_item, their_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.

Great use of .swap_items() as a helper function to DRY your code!

Comment thread swap_meet/vendor.py

def get_by_category(self, category):
# Return a list of item inventory from that category
return [item for item in self.inventory if item.category == 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.

Nice list comprehension!

Comment thread swap_meet/vendor.py
def swap_items(self, other, my_item, their_item):

# Check if Vendor items not in her inventory or Vendor friend's item not in their inventory
if not my_item in self.inventory or not their_item in other.inventory:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great check!


raise Exception("Complete this test according to comments below.")
#raise Exception("Complete this test according to comments below.")
assert item_a != items
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Close! != is testing for non-equality. We'd want to check that the item_a, item_b, and item_c are not in items since none of their categories are "electronics".


@pytest.mark.skip
assert tai.get_best_by_category("Decor").category == "Decor"
assert jesse.get_best_by_category("Clothing").category == "Clothing"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍🏻

# - That all the correct items are in tai and jesse's inventories
assert item_a in tai.inventory
assert item_b in tai.inventory
assert item_c in tai.inventory
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍🏻

# - That all the correct items are in tai and jesse's inventories
assert item_a in tai.inventory
assert item_b in tai.inventory
assert item_c in tai.inventory
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍🏻

# - That all the correct items are in tai and jesse's inventories, and that the items that were swapped are not there

@pytest.mark.skip
assert tai.get_best_by_category("Decor").category == "Decor"
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 check! It would also be helpful to assert that the items that were swapped are not in their original inventories!

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