-
Notifications
You must be signed in to change notification settings - Fork 71
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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!
def __init__(self, category = "Clothing", condition = 0): | ||
self.category = "Clothing" | ||
self.condition = condition | ||
|
||
super().__init__("Clothing", condition) |
There was a problem hiding this comment.
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:
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") |
if item in self.inventory: | ||
self.inventory.remove(item) | ||
else: | ||
return False |
There was a problem hiding this comment.
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:
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: |
There was a problem hiding this comment.
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
self.remove(own_item) | ||
friend.add(own_item) | ||
friend.remove(friend_item) | ||
self.add(friend_item) |
There was a problem hiding this comment.
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!
if category_by_list == []: | ||
return None |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
No description provided.