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

Paper_Karla T_C15 #54

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

Paper_Karla T_C15 #54

wants to merge 6 commits into from

Conversation

ktiktok96
Copy link

No description provided.

@@ -0,0 +1,9 @@
from swap_meet.item import Item
class Clothing(Item):
pass

Choose a reason for hiding this comment

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

pass is a Python placeholder to avoid syntax errors before code is added. Once code is added pass can be removed.

Comment on lines +4 to +6
def __init__(self,condition = 0.0):
self.category = "Clothing"
self.condition = condition

Choose a reason for hiding this comment

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

Another way to write this is to use super to take advantage of the code in Item's constructor:

def __init__(self, condition = 0.0):
    super().__init__("Clothing", condition)

Comment on lines +9 to +20
if self.condition == 0:
return "mint condition"
elif self.condition == 1:
return "like new"
elif self.condition == 2:
return "gently used"
elif self.condition == 3:
return "used"
elif self.condition == 4:
return "clean this before using it"
elif self.condition == 5:
return "Please clean 2x over"

Choose a reason for hiding this comment

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

Condition can have a decimal - what happens if the condition is 3.5? How could you change this section to account for those conditions?

self.inventory= []
else:
self.inventory = inventory
def add(self, add_item):

Choose a reason for hiding this comment

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

For readability I recommend placing a blank line between the end of one function and the beginning of the next.

def swap_items(self, vendor, my_item, their_item):
if my_item not in self.inventory or their_item not in vendor.inventory:
return False
if my_item in self.inventory and their_item in vendor.inventory:

Choose a reason for hiding this comment

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

The conditional on line 24 will catch the case where an inventory doesn't have the item, so this check isn't needed. If the function gets to this point, each item must be in the correct inventory.

if len(self.inventory) > 0 and len(vendor.inventory) > 0:
my_first_item = self.inventory [0]
their_first_item = vendor.inventory[0]
return self.swap_items(vendor, my_first_item, their_first_item) #adjusted line for "DRY"

Choose a reason for hiding this comment

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

Excellent code reuse!

my_item = self.get_best_by_category(their_priority)
their_item = other.get_best_by_category(my_priority)
if my_item and their_item:
return self.swap_items(other, my_item, their_item) #adjusted line for "DRY"

Choose a reason for hiding this comment

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

Nice!

@jbieniosek
Copy link

Great work on this project! Your use of helper functions in Vender is excellent. I have a few stylistic comments to improve readability, but overall this is a very solid project.

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