-
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
Scissors - Mariela C. #62
base: master
Are you sure you want to change the base?
Changes from all commits
25e2b0d
209fad0
e5355cc
beedba0
755abd1
ed3a3ab
2df92e2
b40cacc
954a616
b96716c
1fb6b77
1f3a144
706fd17
3a27923
b51642e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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." | ||
|
||
|
||
|
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." | ||
|
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." | ||
|
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" | ||
|
||
|
||
|
||
|
||
|
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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great that the code makes use of |
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great that you used |
||
|
||
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 | ||
|
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.
Love these :D