Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap_meet_Sumitra Chhetri, Scissor class #60

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

sumitrac
Copy link

@sumitrac sumitrac commented Apr 7, 2021

No description provided.

Copy link

@beccaelenzil beccaelenzil left a comment

Choose a reason for hiding this comment

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

Great work on your first OOP project. You've met the learning goals of reading tests, using inheritance and composition, and using helper methods. Your code is logical and readable. I've left a few comments of ways you could consider refactoring. Keep up the hard work!

Comment on lines +9 to +13
def __init__(self, category = "Clothing", condition = 0):
self.category = "Clothing"
self.condition = condition

super().__init__("Clothing", condition)

Choose a reason for hiding this comment

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

You've done the same work multiple times, consider refactoring like this:

Suggested change
def __init__(self, category = "Clothing", condition = 0):
self.category = "Clothing"
self.condition = condition
super().__init__("Clothing", condition)
def __init__(self, condition = 0):
super().__init__(condition, category="Clothing")

Comment on lines +22 to +25
if item in self.inventory:
self.inventory.remove(item)
else:
return False

Choose a reason for hiding this comment

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

Consider refactoring to address the edge case first:

Suggested change
if item in self.inventory:
self.inventory.remove(item)
else:
return False
if item not in self.inventory:
return False
self.inventory.remove(item)

input: adds and removes items from each Vendor inventory
output: Return True or False
"""
if my_item in self.inventory and their_item in friend_vendor.inventory:

Choose a reason for hiding this comment

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

Consider refactoring to check the edge case first (similar to the comment for remove

Comment on lines +70 to +73
self.remove(own_item)
friend.add(own_item)
friend.remove(friend_item)
self.add(friend_item)

Choose a reason for hiding this comment

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

You can make use of swap_items here!

Comment on lines +89 to +90
if category_by_list == []:
return None

Choose a reason for hiding this comment

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

consider initializing best_item = None which removes the need for this conditional test.

return best_item


def swap_best_by_category(self, other, my_priority, their_priority):

Choose a reason for hiding this comment

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

This function is clear and concise! Great work.

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