-
Notifications
You must be signed in to change notification settings - Fork 110
Cheetahs - Emma #86
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
base: master
Are you sure you want to change the base?
Cheetahs - Emma #86
Changes from all commits
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 |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| class Clothing: | ||
| pass | ||
| from swap_meet.item import Item | ||
|
|
||
| class Clothing(Item): | ||
| def __init__(self, category="Clothing", condition=0) -> None: | ||
| super().__init__(category, condition) | ||
|
|
||
| def __str__(self): | ||
| return "The finest clothing you could wear." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| class Decor: | ||
| pass | ||
| from swap_meet.item import Item | ||
|
|
||
| class Decor(Item): | ||
| def __init__(self, category="Decor", condition=0) -> None: | ||
| super().__init__(category, condition) | ||
|
|
||
| def __str__(self): | ||
| return "Something to decorate your space." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| class Electronics: | ||
| pass | ||
| from swap_meet.item import Item | ||
|
|
||
| class Electronics(Item): | ||
| def __init__(self, category="Electronics", condition=0) -> None: | ||
| super().__init__(category, condition) | ||
|
|
||
| def __str__(self): | ||
| return "A gadget full of buttons and secrets." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,21 @@ | ||
| class Item: | ||
| pass | ||
| def __init__(self, category="", condition=0) -> None: | ||
| self.category = category | ||
| self.condition = condition | ||
|
|
||
| def __str__(self): | ||
| return "Hello World!" | ||
|
|
||
| def condition_description(self): | ||
| if self.condition == 0: | ||
| return "Very Poor" | ||
| elif self.condition == 1: | ||
| return "Poor" | ||
| elif self.condition == 2: | ||
| return "Fair" | ||
| elif self.condition == 3: | ||
| return "Good" | ||
| elif self.condition == 4: | ||
| return "Very Good" | ||
| elif self.condition == 5.0: | ||
| return "Exceptional" | ||
|
Comment on lines
+9
to
+21
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. Conditions can be a float, but this function will only work for whole numbers. If an item has a condition of 3.5, this function will return |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,60 @@ | ||
| from nis import cat | ||
| from .item import Item | ||
|
|
||
| class Vendor: | ||
| pass | ||
| def __init__(self, inventory=None) -> None: | ||
| if inventory is None: | ||
| inventory = [] | ||
| 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 | ||
| return False | ||
|
|
||
| def get_by_category(self, category): | ||
| items_list = [] | ||
| for item in self.inventory: | ||
| if item.category == category: | ||
| items_list.append(item) | ||
Emmakizil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return items_list | ||
|
|
||
| def swap_items(self, friend, my_item, their_item): | ||
| if my_item in self.inventory and their_item in friend.inventory: | ||
| self.remove(my_item) | ||
| friend.add(my_item) | ||
| friend.remove(their_item) | ||
| self.add(their_item) | ||
Emmakizil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return True | ||
| return False | ||
|
|
||
| def swap_first_item(self, friend): | ||
| if not self.inventory or not friend.inventory: | ||
| return False | ||
| self.add(friend.inventory.pop(0)) | ||
| friend.add(self.inventory.pop(0)) | ||
|
Comment on lines
+39
to
+40
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. Could you use |
||
| return True | ||
|
|
||
| def get_best_by_category(self, category): | ||
| categories = self.get_by_category(category) | ||
| if not categories: | ||
| return None | ||
| best_item = categories[0] | ||
| for item in categories: | ||
| if item.condition > best_item.condition: | ||
| best_item = item | ||
| return best_item | ||
Emmakizil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def swap_best_by_category(self, other, my_priority, their_priority): | ||
| my_best_category = self.get_best_by_category(their_priority) | ||
| their_best_category = other.get_best_by_category(my_priority) | ||
|
|
||
| if my_best_category and their_best_category: | ||
| self.swap_items(other, my_best_category, their_best_category) | ||
Emmakizil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return True | ||
| return False | ||
Uh oh!
There was an error while loading. Please reload this page.