diff --git a/swap_meet/clothing.py b/swap_meet/clothing.py new file mode 100644 index 000000000..900ef0062 --- /dev/null +++ b/swap_meet/clothing.py @@ -0,0 +1,10 @@ +from swap_meet.item import Item + + +class Clothing(Item): + + def __init__(self, condition = 0): + super().__init__(category= "Clothing", condition = condition) + + def __str__(self): + return "The finest clothing you could wear." \ No newline at end of file diff --git a/swap_meet/decor.py b/swap_meet/decor.py new file mode 100644 index 000000000..8fc96c1fb --- /dev/null +++ b/swap_meet/decor.py @@ -0,0 +1,9 @@ +from swap_meet.item import Item + +class Decor(Item): + + def __init__(self, condition = 0): + super().__init__(category= "Decor", condition = condition) + + def __str__(self): + return "Something to decorate your space." \ No newline at end of file diff --git a/swap_meet/electronics.py b/swap_meet/electronics.py new file mode 100644 index 000000000..273058634 --- /dev/null +++ b/swap_meet/electronics.py @@ -0,0 +1,9 @@ +from swap_meet.item import Item + +class Electronics(Item): + + def __init__(self, condition = 0): + super().__init__(category= "Electronics", condition = condition) + + def __str__(self): + return "A gadget full of buttons and secrets." \ No newline at end of file diff --git a/swap_meet/item.py b/swap_meet/item.py new file mode 100644 index 000000000..cafde4946 --- /dev/null +++ b/swap_meet/item.py @@ -0,0 +1,21 @@ +class Item: + def __init__(self, category = "", condition = 0): + self.category = category + self.condition = condition + + def __str__(self): + return "Hello World!" + + def condition_description(self): + if self.condition == 0: + return "This should have been recycled." + elif self.condition == 1: + return "This is really bad." + elif self.condition == 2: + return "This is in somewhat okay condition." + elif self.condition == 3: + return "This is in decent condition." + elif self.condition == 4: + return "This almost looks new!" + elif self.condition == 5: + return "This looks so new! Very nice." \ No newline at end of file diff --git a/swap_meet/vendor.py b/swap_meet/vendor.py new file mode 100644 index 000000000..1b316d455 --- /dev/null +++ b/swap_meet/vendor.py @@ -0,0 +1,72 @@ +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 + + def get_by_category(self, category): + category_list =[] + for items in self.inventory: + if items.category == category: + category_list.append(items) + return category_list + +#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 + self.remove(my_item) + friend_vendor.add(my_item) + friend_vendor.remove(their_item) + self.add(their_item) + return True + + +#Wave 4 ********************************** + + 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 + +#Wave 6 *************************** + + 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 + + + def swap_best_by_category(self, other, my_priority, their_priority): + best_in_my_inventory = self.get_best_by_category(their_priority) + best_item_in_other = other.get_best_by_category(my_priority) + if best_item_in_other == None or best_in_my_inventory == None: + return False + self.swap_items(other, best_in_my_inventory, best_item_in_other) + return True \ No newline at end of file