-
Notifications
You must be signed in to change notification settings - Fork 71
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 - Drew Taylor #56
base: master
Are you sure you want to change the base?
Conversation
…ing everything to be true. The skeleton of Wave complete as well
from swap_meet.item import Item | ||
|
||
|
||
class Clothing(Item): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 perfectly done! this is a great example of inheritance and using the super class
@@ -0,0 +1,9 @@ | |||
from swap_meet.item import Item | |||
|
|||
class Decor(Item): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -0,0 +1,9 @@ | |||
from swap_meet.item import Item | |||
|
|||
class Electronics(Item): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -0,0 +1,21 @@ | |||
class Item: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
def __str__(self): | ||
return "Hello World!" | ||
|
||
def condition_description(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
else: | ||
return False | ||
|
||
def get_by_category(self, category): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
#Wave 3 ***************************** | ||
|
||
def swap_items(self, friend_vendor, my_item, their_item): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
def swap_first_item(self, friend): | ||
|
||
if len(self.inventory) == 0 or len(friend.inventory) == 0: | ||
return False | ||
first_item = self.inventory[0] | ||
self.remove(self.inventory[0]) | ||
self.add(friend.inventory[0]) | ||
friend.remove(friend.inventory[0]) | ||
friend.add(first_item) | ||
|
||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 this works perfectly, but I think we are already doing this on lines 30 - 36. So let's try something like this:
def swap_first_item(self, friend): | |
if len(self.inventory) == 0 or len(friend.inventory) == 0: | |
return False | |
first_item = self.inventory[0] | |
self.remove(self.inventory[0]) | |
self.add(friend.inventory[0]) | |
friend.remove(friend.inventory[0]) | |
friend.add(first_item) | |
return True | |
def swap_first_item(self, friend): | |
return self.swap_items(friend, self.inventory[0], friend.inventory[0]) |
we have a method that already swaps items, so we should use it!
def get_best_by_category(self, category): | ||
highest_condition = 0 | ||
highest_item = None | ||
for item in self.inventory: | ||
if item.category == category: | ||
if item.condition > highest_condition: | ||
highest_condition = item.condition | ||
highest_item = item | ||
return highest_item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 this works great! we could also bring in get_by_category
method to get all the items of that category then run through them, but your way actually saves you a for loop!
so this is just fine
return highest_item | ||
|
||
|
||
def swap_best_by_category(self, other, my_priority, their_priority): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good job using your other methods to make your code DRY
No description provided.