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 Swap Meet - Araceli #71

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

Conversation

aracelim1234
Copy link

No description provided.

Copy link

@jmaddox19 jmaddox19 left a comment

Choose a reason for hiding this comment

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

A lot of what's here looks good. You successfully wrote classes with instance methods that appropriately interact with instance variables, which is great!

That said there are a few learning goals that aren't met as the code is written:

  • There is no usage of inheritance (and therefore no chance to override methods)
  • There are several missed opportunities to DRY up the code by calling instance methods from other methods
  • 3 of the methods don't do what the README and the tests direct them to

If you can, I would encourage you to see if you can update the code to address each of these things to solidly fulfill the learning goals for this project.

Comment on lines +2 to +14
import pytest
from swap_meet.vendor import Vendor
from swap_meet.item import Item


item_a = Item(category="clothing")
item_b = Item(category="electronics")
item_c = Item(category="clothing")
vendor = Vendor(
inventory=[item_a, item_b, item_c]
)

items = vendor.get_by_category("clothing")

Choose a reason for hiding this comment

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

Love that you did some of your own experimenting with a separate main.py file!

Comment on lines 14 to 23
if self.condition == 1:
return "Geez, maybe put that back."
elif self.condition == 2:
return "Well, could be worse."
elif self.condition == 3:
return "What are the savings from retail value?"
elif self.condition == 4:
return "Almost in perfect condition"
elif self.condition == 5:
return "I am delighted from the sun and back"

Choose a reason for hiding this comment

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

Love these :D

Comment on lines 13 to 22
if self.condition == 1:
return "Geez, maybe put that back."
elif self.condition == 2:
return "Well, could be worse."
elif self.condition == 3:
return "What are the savings from retail value?"
elif self.condition == 4:
return "Almost in perfect condition"
elif self.condition == 5:
return "I am delighted from the sun and back"

Choose a reason for hiding this comment

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

If the Clothing, Decor, and Electronics classes were written to inherit from Item, this method could go in the Item class instead and it wouldn't need to be repeated in 3 different classes. I would encourage you to take time to see if you can rewrite these classes to use inheritance.

@@ -0,0 +1,22 @@
class Decor:

Choose a reason for hiding this comment

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

This is the first of many changes that'd need to be made to this class definition to properly inherit from the Item class.

Suggested change
class Decor:
class Decor(Item):

self.my_item = my_item
self.their_item = their_item

if my_item == True and their_item == True:

Choose a reason for hiding this comment

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

This will never evaluate to true so the method will never actually appropriately swap the items.


self.inventory[0] = their_first_item
other.inventory[0] = my_first_item
return bool(self.inventory)

Choose a reason for hiding this comment

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

I'm curious to know why this is written this way. This will return true as long as the list isn't empty, and there's in if check above to already ensure the list isn't empty, so this should always return True anyway.

Suggested change
return bool(self.inventory)
return True

Comment on lines 66 to 68
for item in self.inventory:
if item.category == category:
best_in_category.append(item)

Choose a reason for hiding this comment

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

With the conditional on line 71, there's actually no need for this step. Right now the same check is happening twice.

Suggested change
for item in self.inventory:
if item.category == category:
best_in_category.append(item)

if item.category == category:
best_in_category.append(item)

for item in best_in_category:

Choose a reason for hiding this comment

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

Suggested change
for item in best_in_category:
for item in self.inventory:

Comment on lines 72 to 82
for condition in best_in_category:
if item.condition == 5.0:
return item
elif item.condition == 4.0:
return item
elif item.condition == 3.0:
return item
elif item.condition == 2.0:
return item
elif item.condition == 1.0:
return itme

Choose a reason for hiding this comment

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

This will always return the first item in the list, no matter what.
I'd encourage you to run the tests with the debugger and seek to understand how this is working and why it isn't doing what you intended.

Comment on lines 88 to 91
if my_priority not in other.inventory or their_priority not in self.inventory:
return False
else:
return True

Choose a reason for hiding this comment

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

There's no swapping actually happening here. If swap_items were rewritten to work properly, we could make use of that method by calling it from here.

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