From 25e2b0d1732a5e50cd71c96122794faad95010fb Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Sat, 3 Apr 2021 19:02:13 -0700 Subject: [PATCH 01/15] Added new methods to vendor anand item --- swap_meet/item.py | 3 +++ swap_meet/vendor.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 swap_meet/item.py create mode 100644 swap_meet/vendor.py diff --git a/swap_meet/item.py b/swap_meet/item.py new file mode 100644 index 000000000..0a7e5d198 --- /dev/null +++ b/swap_meet/item.py @@ -0,0 +1,3 @@ +class Item: + def __init__(self,category = ""): + self.category = category diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py new file mode 100644 index 000000000..ce966d112 --- /dev/null +++ b/swap_meet/vendor.py @@ -0,0 +1,43 @@ +from swap_meet.item import Item +# or is it from .item import Item +# what is the difference between these two type of imports + +# ---------- 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 2 -------------- +# you need to call the item 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 3 ------------- +# \ No newline at end of file From 209fad0326ad8c69c9507a37a25a798d885b2716 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Mon, 5 Apr 2021 16:56:39 -0700 Subject: [PATCH 02/15] Added swap items method --- swap_meet/item.py | 3 +++ swap_meet/vendor.py | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/swap_meet/item.py b/swap_meet/item.py index 0a7e5d198..f323fcbbb 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,3 +1,6 @@ class Item: def __init__(self,category = ""): self.category = category + + # def __str__(self,): + # return "Hello World" diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index ce966d112..8fc3afe77 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -22,6 +22,21 @@ def remove(self,item): return item else: return False + + + + +# --------------- Wave 3 -------------- + def swap_items(self,friend_vendor,my_item,their_item): + 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 + @@ -39,5 +54,20 @@ def get_by_category(self,category): return items -# ------------- Wave 3 ------------- -# \ No newline at end of file + + +# ------------- Wave 4 ------------- + + + + + + + + + +# ------------- Wave 5 ------------- + + + +# ------------- Wave 6 ------------- \ No newline at end of file From e5355cc6d8a8275e4ad92c8f57fe1f663e48d641 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Mon, 5 Apr 2021 18:08:29 -0700 Subject: [PATCH 03/15] added a stringify method --- swap_meet/clothing.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 swap_meet/clothing.py diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py new file mode 100644 index 000000000..3e3b4d331 --- /dev/null +++ b/swap_meet/clothing.py @@ -0,0 +1,8 @@ +# ----------- WAVE 4 ----------- + +class Clothing: + def __init__ (self): + self.category = "Clothing" + + def __str__(self): + return "The finest clothing you could wear." \ No newline at end of file From beedba0755b3a463de4645866520205dbd51d30a Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Mon, 5 Apr 2021 18:09:32 -0700 Subject: [PATCH 04/15] added a stringify method --- swap_meet/decor.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 swap_meet/decor.py diff --git a/swap_meet/decor.py b/swap_meet/decor.py new file mode 100644 index 000000000..6e7c9e195 --- /dev/null +++ b/swap_meet/decor.py @@ -0,0 +1,6 @@ +class Decor: + def __init__(self): + self.category = "Decor" + def __str__(self): + return "Something to decorate your space." + \ No newline at end of file From 755abd13a33f538e0d9b1ecdfb8646a2a67a5004 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Mon, 5 Apr 2021 18:10:32 -0700 Subject: [PATCH 05/15] added a stringify method --- swap_meet/electronics.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 swap_meet/electronics.py diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py new file mode 100644 index 000000000..f38d6f593 --- /dev/null +++ b/swap_meet/electronics.py @@ -0,0 +1,5 @@ +class Electronics: + def __init__(self): + self.category = "Electronics" + def __str__(self): + return "A gadget full of buttons and secrets." From ed3a3ab5187791db8a6086e7da2afa3efc71c0d0 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Mon, 5 Apr 2021 18:12:04 -0700 Subject: [PATCH 06/15] added a stringigy method --- swap_meet/item.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/swap_meet/item.py b/swap_meet/item.py index f323fcbbb..9d80aba23 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,6 +1,5 @@ class Item: def __init__(self,category = ""): self.category = category - - # def __str__(self,): - # return "Hello World" + def __str__(self): + return "Hello World!" \ No newline at end of file From 2df92e2baf41f77ac7626cfb76865f3b25f9fade Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Mon, 5 Apr 2021 20:53:12 -0700 Subject: [PATCH 07/15] added str method --- swap_meet/clothing.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index 3e3b4d331..9109f1f52 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -1,8 +1,14 @@ # ----------- WAVE 4 ----------- - -class Clothing: +from swap_meet.item import Item +class Clothing(Item): def __init__ (self): + super() self.category = "Clothing" + # self.condition = 0 def __str__(self): - return "The finest clothing you could wear." \ No newline at end of file + return "The finest clothing you could wear." + # def condition_description(self,condition): + # if item + + From b40cacc9d04d9c97f9b5644d6f1dea5c9bb3512c Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Mon, 5 Apr 2021 20:58:42 -0700 Subject: [PATCH 08/15] implemented a swap_first_item methd --- swap_meet/vendor.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 8fc3afe77..1e93d1b58 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -58,7 +58,17 @@ def get_by_category(self,category): # ------------- Wave 4 ------------- - + def swap_first_item(self,friend_vendor): + # if not self.inventory or not friend_vendor.inventory: + # return False + 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.inventory.remove(first_item) + self.swap_items(friend_vendor,first_item,first_friend_item) + return True @@ -70,4 +80,9 @@ def get_by_category(self,category): + + + + + # ------------- Wave 6 ------------- \ No newline at end of file From 954a61624f785374f4c4b7b83f52f2bdae495877 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Tue, 6 Apr 2021 16:19:14 -0700 Subject: [PATCH 09/15] updated class clothing to child class that inherited from the parent calss Item --- swap_meet/clothing.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index 9109f1f52..bb5ebd348 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -1,14 +1,15 @@ # ----------- WAVE 4 ----------- from swap_meet.item import Item class Clothing(Item): - def __init__ (self): - super() + def __init__ (self, condition=0, category ="Clothing"): + super().__init__("Clothing", condition) self.category = "Clothing" - # self.condition = 0 + self.condition = condition def __str__(self): return "The finest clothing you could wear." - # def condition_description(self,condition): - # if item + + # def condition_description(self): + # return super().condition_description() From b96716c3fcc2655dde6bdf1ed1cb51c1ad601923 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Tue, 6 Apr 2021 16:20:45 -0700 Subject: [PATCH 10/15] updated class decor that inherited from the parent item class --- swap_meet/decor.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/swap_meet/decor.py b/swap_meet/decor.py index 6e7c9e195..171211939 100644 --- a/swap_meet/decor.py +++ b/swap_meet/decor.py @@ -1,6 +1,14 @@ -class Decor: - def __init__(self): + +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." + + # def condition_description(self): + # return super().condition_description() \ No newline at end of file From 1fb6b77c6629740a9b302f7e1f7770199fd03a93 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Tue, 6 Apr 2021 16:22:28 -0700 Subject: [PATCH 11/15] added get best category method that returned the best item from that category --- swap_meet/vendor.py | 47 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index 1e93d1b58..d8f44e405 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -72,17 +72,42 @@ def swap_first_item(self,friend_vendor): - - - - # ------------- Wave 5 ------------- +# this is using inheritance 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) + + 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 from my priority category + my_category = self.get_best_by_category(my_priority) + # this will return the best item from thier priority category + other_category = self.get_best_by_category(their_priority) + + # self.swap_items(friend_vendor,my_item,their_item): + if other_category not in self.inventory or my_category not in other.inventory: + return False + else: + self.inventory.remove(my_category) + other.inventory.append(my_category) + other.inventory.remove(other_category) + self.inventory.append(other_category) + return True - - - - - - -# ------------- Wave 6 ------------- \ No newline at end of file From 1f3a144f07b779ad36593104c1629754dd847d76 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Tue, 6 Apr 2021 17:48:57 -0700 Subject: [PATCH 12/15] added a swap_best_by_category method that returns the best item from the respective category --- swap_meet/vendor.py | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py index d8f44e405..6bb465a86 100644 --- a/swap_meet/vendor.py +++ b/swap_meet/vendor.py @@ -1,6 +1,4 @@ from swap_meet.item import Item -# or is it from .item import Item -# what is the difference between these two type of imports # ---------- Wave 1 ----------- @@ -43,8 +41,7 @@ def swap_items(self,friend_vendor,my_item,their_item): # --------------- Wave 2 -------------- -# you need to call the item file in order to access the -# category list +# 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 = [] @@ -59,21 +56,18 @@ def get_by_category(self,category): # ------------- Wave 4 ------------- def swap_first_item(self,friend_vendor): - # if not self.inventory or not friend_vendor.inventory: - # return False 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.inventory.remove(first_item) self.swap_items(friend_vendor,first_item,first_friend_item) return True # ------------- Wave 5 ------------- -# this is using inheritance and the super method +# this is using inheritance/ child and parent class and the super method # ------------- Wave 6 ------------- @@ -93,21 +87,14 @@ def get_best_by_category(self, category): return quality_item - def swap_best_by_category(self,other,my_priority,their_priority): - # this will return the best item from my priority category - my_category = self.get_best_by_category(my_priority) - # this will return the best item from thier priority category - other_category = self.get_best_by_category(their_priority) - - # self.swap_items(friend_vendor,my_item,their_item): - if other_category not in self.inventory or my_category not in other.inventory: - return False - else: - self.inventory.remove(my_category) - other.inventory.append(my_category) - other.inventory.remove(other_category) - self.inventory.append(other_category) - return True + # 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 From 706fd175a4d34f97f99f290cd9510c73a56e41da Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Tue, 6 Apr 2021 17:51:41 -0700 Subject: [PATCH 13/15] added a super method --- swap_meet/clothing.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py index bb5ebd348..80bbfd3dc 100644 --- a/swap_meet/clothing.py +++ b/swap_meet/clothing.py @@ -9,7 +9,5 @@ def __init__ (self, condition=0, category ="Clothing"): def __str__(self): return "The finest clothing you could wear." - # def condition_description(self): - # return super().condition_description() From 3a2792325eea2e2a0944ddca2eee77596dfdc2d3 Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Tue, 6 Apr 2021 21:42:21 -0700 Subject: [PATCH 14/15] updated electronics as a child class and Item as the parent class. --- swap_meet/decor.py | 3 --- swap_meet/electronics.py | 11 +++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/swap_meet/decor.py b/swap_meet/decor.py index 171211939..8fc454384 100644 --- a/swap_meet/decor.py +++ b/swap_meet/decor.py @@ -8,7 +8,4 @@ def __init__(self,condition=0, category="Decor"): self.condition = condition def __str__(self): return "Something to decorate your space." - - # def condition_description(self): - # return super().condition_description() \ No newline at end of file diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py index f38d6f593..3fe4e6fc4 100644 --- a/swap_meet/electronics.py +++ b/swap_meet/electronics.py @@ -1,5 +1,12 @@ -class Electronics: - def __init__(self): + +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." + From b51642e44b0aa8fc841bed3b6a013d6d63b75e5b Mon Sep 17 00:00:00 2001 From: marielaxcruz Date: Tue, 6 Apr 2021 21:48:48 -0700 Subject: [PATCH 15/15] added the condition_description method to test for item condition --- swap_meet/item.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/swap_meet/item.py b/swap_meet/item.py index 9d80aba23..70b0229b7 100644 --- a/swap_meet/item.py +++ b/swap_meet/item.py @@ -1,5 +1,23 @@ +# this will be the parent class class Item: - def __init__(self,category = ""): + def __init__(self, condition = 0, category = ""): self.category = category + self.condition = condition def __str__(self): - return "Hello World!" \ No newline at end of file + 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" + + + + +