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 - Stella #63

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

Scissors - Stella #63

wants to merge 2 commits into from

Conversation

stlashi
Copy link

@stlashi stlashi 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 (and writing!) tests and using composition and inheritance. Your code is logical and readable, and you've made great use of helper functions. I've left a few comments on small ways you could consider refactoring, and ideas on a few additional tests/assertions. Keep up the hard work!


#Wave 5:
class Decor(Item):
def __init__(self,condition = 0, age =0):

Choose a reason for hiding this comment

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

Good use of super/inheritance.

Comment on lines +16 to +20
if item in self.inventory:
self.inventory.remove(item)
return 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 using the pattern where you check the edge case first:

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

def swap_items(self,friend, my_item, their_item):
#if len(self.inventory) == 0 or len(friend.inventory) ==0:
#return False
if my_item in self.inventory and their_item in friend.inventory:

Choose a reason for hiding this comment

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

Consider refactoring so you check the condition where you return False first, and then move the main logic out of the conditional.

if len(self.inventory) == 0 or len(friend.inventory) ==0:
return False
else:
return self.swap_items(friend,self.inventory[0],friend.inventory[0])

Choose a reason for hiding this comment

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

You can move this line our of the else to enhance readability.

best_condition = item.condition
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.

Wow! So efficient. Good use of the previous methods as helper functions.



#Wave 7 - Optional Enhancement
#Helper function - get item with the min age

Choose a reason for hiding this comment

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

Great work implementing this optional part.

jesse = Vendor(inventory=[item_d, item_e])
result = tai.swap_by_newest(jesse)

assert result is True

Choose a reason for hiding this comment

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

Good work writing your own tests! It's good practice to add a few more assertions here to make sure that the swap actually happened. Check that tai now has item_d and jesse has item_a (did I get that right?). I would also add an edge case test. What happens when the vendors have no inventory? What happens when all the items in their inventory have the same age?

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