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 - Drew Taylor #56

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

Rock - Drew Taylor #56

wants to merge 5 commits into from

Conversation

seraphina97
Copy link

No description provided.

from swap_meet.item import Item


class Clothing(Item):

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):

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):

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:

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):

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):

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):

Choose a reason for hiding this comment

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

👍

Comment on lines +41 to +51
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

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:

Suggested change
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!

Comment on lines +55 to +63
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

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):

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

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