-
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
Scissors // Raquel Mena #51
base: master
Are you sure you want to change the base?
Conversation
…_description method"
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.
Wow! Great work on your first OOP project. You've met the learning goals around working with composition, inheritance, working on a project with multiple files, and reading tests. Your code is logical and readable. I've made a few suggestions of small ways you might consider refactoring. Keep up the hard work!
@@ -0,0 +1,8 @@ | |||
from .item import Item | |||
|
|||
class Clothing(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.
Good use of inheritance/super()
self.remove(my_item) | ||
friend.add(my_item) | ||
friend.remove(friends_item) | ||
self.add(friends_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.
great use of add
and remove
as helper function
self.swap_items(friend, self.inventory[0], friend.inventory[0]) | ||
return True |
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 moving this outside of the else
clause.
if my_item in self.inventory and friends_item in friend.inventory: | ||
# friend.add(self.remove(my_item)) | ||
# self.add(friend.remove(friends_item)) | ||
self.remove(my_item) | ||
friend.add(my_item) | ||
friend.remove(friends_item) | ||
self.add(friends_item) | ||
return True | ||
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 reorganizing like this to deal with the edge case first and move the main logic of the function out from being nested.
if my_item in self.inventory and friends_item in friend.inventory: | |
# friend.add(self.remove(my_item)) | |
# self.add(friend.remove(friends_item)) | |
self.remove(my_item) | |
friend.add(my_item) | |
friend.remove(friends_item) | |
self.add(friends_item) | |
return True | |
else: | |
return False | |
if my_item not in self.inventory or friends_item not in friend.inventory: | |
return False | |
self.remove(my_item) | |
friend.add(my_item) | |
friend.remove(friends_item) | |
self.add(friends_item) | |
return True |
No description provided.