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

Rock - Priscille #50

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

Rock - Priscille #50

wants to merge 11 commits into from

Conversation

Priscillesg
Copy link

No description provided.

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

Choose a reason for hiding this comment

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

👍 this works perfectly! But it still lets the user change the category, and we don't want that. class Clothing will always have the category "clothing." So let's try this:

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

@@ -0,0 +1,10 @@
from swap_meet.item import Item

class Decor(Item):

Choose a reason for hiding this comment

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

👍 We can do the same thing here as we did above!

@@ -0,0 +1,10 @@
from swap_meet.item import Item

class Electronics(Item):

Choose a reason for hiding this comment

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

👍 We can do the same thing here as we did above!

Comment on lines +3 to +15
def __init__(self, category = "", condition = 0, age = 0):
if category is None:
self.category = ""
else:
self.category = category
if condition is None:
self.condition = 0
else:
self.condition = condition
if age is None:
self.age = 0
else:
self.age = age

Choose a reason for hiding this comment

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

this works good! But our default parameters, like category="" already do what the if-else statements do. so let's let the default parameters do all the work.

Suggested change
def __init__(self, category = "", condition = 0, age = 0):
if category is None:
self.category = ""
else:
self.category = category
if condition is None:
self.condition = 0
else:
self.condition = condition
if age is None:
self.age = 0
else:
self.age = age
def __init__(self, category = "", condition = 0, age = 0):
self.category = category
self.condition = condition
self.age = age

now category will be assigned "" if the user doesn't add in an argument. It will do what if-else statements are doing for us!

def __str__(self):
return "Hello World!"

def condition_description(self):

Choose a reason for hiding this comment

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

👍

Comment on lines +42 to +44
item_a = self.inventory[0]
item_d = vendor_friend.inventory[0]
result = self.swap_items(vendor_friend, item_a, item_d)

Choose a reason for hiding this comment

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

we could get rid of these two variables if we wanted!

Suggested change
item_a = self.inventory[0]
item_d = vendor_friend.inventory[0]
result = self.swap_items(vendor_friend, item_a, item_d)
result = self.swap_items(vendor_friend, self.inventory[0], vendor_friend.inventory[0])

result = self.swap_items(vendor_friend, item_a, item_d)
return result

def get_best_by_category(self, category_name):

Choose a reason for hiding this comment

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

👍

best_item = item
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.

👍


# Optional Enhancements: item by age

def get_newest_item(self):

Choose a reason for hiding this comment

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

👍

newest_item = item
return newest_item

def swap_by_newest(self, business_partner, my_newest_item, their_newest_item):

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