Skip to content

Maple- Sabrina L.#94

Open
SabrinaLauredan wants to merge 6 commits into
Ada-C16:masterfrom
SabrinaLauredan:master
Open

Maple- Sabrina L.#94
SabrinaLauredan wants to merge 6 commits into
Ada-C16:masterfrom
SabrinaLauredan:master

Conversation

@SabrinaLauredan

Copy link
Copy Markdown

No description provided.

@spitsfire spitsfire left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Heck frickin' yeah, Sabrina!! This was very easy to read, very simple and understandable. I left a few suggestions on how to dry up your code, how to take advantage of inheritance, etc., but your logic looks good.

Great job!! Keep it up!

Comment thread swap_meet/clothing.py
Comment on lines +5 to +8
# super().__init__(category = "Clothing")
## super().__init__(condition)
self.category = "Clothing"
self.condition = condition

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

great! lines 7 and 8 totally work, though we could definitely use the parent class' constructor instead! It already creates category and condition attributes for us, so let's look at that:

Suggested change
# super().__init__(category = "Clothing")
## super().__init__(condition)
self.category = "Clothing"
self.condition = condition
# super().__init__(category = "Clothing", condition)

and I like that you hardcoded "Clothing" since of course this child class Clothing will always be category "Clothing." No reason to give the user the opportunity to mess that up haha

Comment thread swap_meet/decor.py
Comment on lines +4 to +7

def __init__(self, condition = 0):
self.category = "Decor"
self.condition = condition

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same as above! we could refactor this a little more to use inheritance more explicitly

Comment thread swap_meet/electronics.py
pass
from swap_meet.item import Item

class Electronics(Item):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread swap_meet/item.py
@@ -1,2 +1,18 @@
class Item:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread swap_meet/vendor.py
@@ -1,2 +1,57 @@
from swap_meet.item import Item

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

so here, we don't actually need to import the literal class Item itself. We aren't instantiating an instance of Item (ie, Item(category="antique",3) ) inside the Vendor anywhere.

There are "items" coming in through parameters, but the class "blueprint" itself can't tell that. On line 7 def add(self, item) the item parameter is simply a placeholder. It could be called banana, apple, and when this method is actually called we could pass an integer, a string, a dictionary, etc. basically, the method itself doesn't know what these parameter values will be.

So unless we are actually creating an instance inside vendor (like our composition examples), we don't need to import it

Comment thread swap_meet/vendor.py
else:
return False

def get_by_category(self, category):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread swap_meet/vendor.py
Comment on lines +27 to +30
self.add(their_item)
friend.add(my_item)
self.remove(my_item)
friend.remove(their_item)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

great job reusing methods you've already made!we can make this even shorter, though:

Suggested change
self.add(their_item)
friend.add(my_item)
self.remove(my_item)
friend.remove(their_item)
self.add(friend.remove(their_item))
friend.add(self.remove(my_item))

if you recall, the remove method returns the item that is removed, so we can call the remove method right inside the add

Comment thread swap_meet/vendor.py
else:
return False

def swap_first_item(self, friend):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread swap_meet/vendor.py
return True
return False

def get_best_by_category(self, category):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread swap_meet/vendor.py
return best


def swap_best_by_category(self, other, my_priority, their_priority):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

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