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! ~ Jittania #64

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

Scissors! ~ Jittania #64

wants to merge 3 commits into from

Conversation

jittania
Copy link

@jittania jittania 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 around reading test and using composition and inheritance. I am particularly impressed by the way you've spelled out the requirements. I've left a few comments on ways you could consider refactoring focused on using super() and using helper methods. Please let me know if you have any questions. Keep up the hard work!

@@ -0,0 +1,129 @@
# Wave 1

Choose a reason for hiding this comment

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

Great work writing down all the requirements!

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

Choose a reason for hiding this comment

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

Consider using super. Category doesn't ever need to be passed in when instantiating a Clothing object since it will always be "clothing"

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

if my_item not in self.inventory or their_item not in friend.inventory:
return False

# take my_item out of my inventory list and adds it to friend's inventory

Choose a reason for hiding this comment

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

Good use of add and remove as help functions.

def swap_items(self, friend, my_item, their_item):

# guard clause (method cannot find my_item or their_item in either inventory list and/or inventories are empty)
if my_item not in self.inventory or their_item not in friend.inventory:

Choose a reason for hiding this comment

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

Nice work dealing with the edge case first.

Comment on lines +53 to +62
# removes first item in `inventory` of `friend` and adds to `inventory` of recipient Vendor
friend_first_item = friend.inventory[0]

friend.remove(friend_first_item)
self.add(friend_first_item)

# removes first item in `inventory` of recipient Vendor and adds to `inventory` of `friend`
self_first_item = self.inventory[0]
self.remove(self_first_item)
friend.add(self_first_item)

Choose a reason for hiding this comment

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

Consider refactoring to use swap_items

Comment on lines +80 to +81
if best_item == 0:
return None

Choose a reason for hiding this comment

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

Consider how if you initiated best_item = None on line 69, lines 80 and 81 wouldn't be necessary.

Comment on lines +90 to +98
for my_item in self.inventory:
if my_item.category == their_priority:
other.add(my_item)
self.remove(my_item)

for other_item in other.inventory:
if other_item.category == my_priority:
self.add(other_item)
other.remove(other_item)
Copy link

@beccaelenzil beccaelenzil Apr 8, 2021

Choose a reason for hiding this comment

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

hrmmm, I'm not sure that this will in fact swap the best of a particular category. It looks like it will swap the first item in the inventory that matches the priorities. This means that our tests aren't thorough enough! To make sure that you're getting the best item of particular category, use get_best_by_category and call it on self and other. You can then use swap_items to swap the items you identify.

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