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

Scissors // Raquel Mena #51

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

Conversation

Raque-lita
Copy link

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.

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):

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()

Comment on lines +33 to +36
self.remove(my_item)
friend.add(my_item)
friend.remove(friends_item)
self.add(friends_item)

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

Comment on lines +48 to +49
self.swap_items(friend, self.inventory[0], friend.inventory[0])
return True

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.

Comment on lines +30 to +39
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

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.

Suggested change
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

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