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 - Mariela C. #62

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions swap_meet/clothing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ----------- WAVE 4 -----------
from swap_meet.item import Item
class Clothing(Item):
def __init__ (self, condition=0, category ="Clothing"):
super().__init__("Clothing", condition)
self.category = "Clothing"
self.condition = condition

def __str__(self):
return "The finest clothing you could wear."



11 changes: 11 additions & 0 deletions swap_meet/decor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

from swap_meet.item import Item

class Decor(Item):
def __init__(self,condition=0, category="Decor"):
super().__init__(category)
self.category = "Decor"
self.condition = condition
def __str__(self):
return "Something to decorate your space."

12 changes: 12 additions & 0 deletions swap_meet/electronics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

from swap_meet.item import Item

class Electronics(Item):
def __init__(self,condition=0, category="Electronics"):
super().__init__(category)
self.category = "Electronics"
self.condition = condition

def __str__(self):
return "A gadget full of buttons and secrets."

23 changes: 23 additions & 0 deletions swap_meet/item.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# this will be the parent class
class Item:
def __init__(self, condition = 0, category = ""):
self.category = category
self.condition = condition
def __str__(self):
return "Hello World!"


def condition_description(self):
if self.condition >= 5:
return "BRAND NEW - STRAIGHT OUT OF THE BOX"
elif self.condition >= 4:
return "Looks Brand New"
elif self.condition >= 3:
return "A few imperfections - Nobody's Perfect!"
elif self.condition >= 1:
return "Fairly Used, Easy DIY fix"
Comment on lines +11 to +18

Choose a reason for hiding this comment

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

Love these :D






100 changes: 100 additions & 0 deletions swap_meet/vendor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from swap_meet.item import Item

# ---------- Wave 1 -----------

class Vendor:
def __init__(self, inventory = None):
if inventory == None:
self.inventory = []
else:
self.inventory = inventory

def add(self, item):
self.inventory.append(item)
return item


def remove(self,item):
if item in self.inventory:
self.inventory.remove(item)
return item
else:
return False




# --------------- 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.

This all works great! That said, this method would be a good place to make use of the add and remove methods above

if my_item not in self.inventory or their_item not in friend_vendor.inventory:
return False
else:
self.inventory.remove(my_item)
friend_vendor.inventory.append(my_item)
friend_vendor.inventory.remove(their_item)
self.inventory.append(their_item)
return True






# --------------- Wave 2 --------------
# you need to call the item.py file in order to access the category list
# list of items in category list
def get_by_category(self,category):
items = []
for new_item in self.inventory:
if new_item.category == category:
items.append(new_item)
return items




# ------------- Wave 4 -------------

def swap_first_item(self,friend_vendor):
if len(self.inventory) == 0 or len(friend_vendor.inventory) == 0:
return False
else:
first_item = self.inventory[0]
first_friend_item = friend_vendor.inventory[0]
self.swap_items(friend_vendor,first_item,first_friend_item)

Choose a reason for hiding this comment

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

Great that the code makes use of swap_items here!

return True



# ------------- Wave 5 -------------
# this is using inheritance/ child and parent class and the super method


# ------------- Wave 6 -------------

def get_best_by_category(self, category):
highest_condition = 0
quality_item = None
matching_category_items = self.get_by_category(category)

Choose a reason for hiding this comment

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

Great that you used get_by_category here!


if matching_category_items == []:
return None

for item in matching_category_items:
if item.condition > highest_condition:
highest_condition = item.condition
quality_item = item

return quality_item

def swap_best_by_category(self,other,my_priority,their_priority):
# this will return the best item in my inventory that matches their_priority category
my_category = self.get_best_by_category(their_priority)
# this will return the best item from other inventory that matches from my_priority category
other_category = other.get_best_by_category(my_priority)
# invoking the method swap items that will swap the best items in their respective categories

total = self.swap_items(other,my_category,other_category)

return total