-
Notifications
You must be signed in to change notification settings - Fork 110
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
Tigers - Maria and Misha #88
base: master
Are you sure you want to change the base?
Changes from all commits
fa35f51
f8c166e
45d9a07
c85b406
28737e4
56b74dd
80cc881
fd5a451
d7ed50e
abd56a3
f7ce3a7
eb0f570
47a8938
cdfa1a7
f10847d
8d20bba
44a9e17
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,10 @@ | ||
class Clothing: | ||
pass | ||
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." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
class Decor: | ||
pass | ||
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." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
class Electronics: | ||
pass | ||
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." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
class Item: | ||
pass | ||
def __init__(self, category = "", condition=0): | ||
self.category = category | ||
self.condition = condition | ||
|
||
|
||
def __str__(self): | ||
return "Hello World!" | ||
|
||
|
||
def condition_description(self): | ||
rating = self.condition | ||
description = ["very gross", "Not that great", "It's okay...", "gently used", "pretty good", "really great!"] | ||
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. Good idea using a list to find the appropriate description based on the index position! |
||
return description[rating] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,66 @@ | ||
class Vendor: | ||
pass | ||
def __init__(self, inventory=None): | ||
self.inventory = inventory if inventory is not None else [] | ||
|
||
|
||
def add(self, added_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. 👍 |
||
self.inventory.append(added_item) | ||
return added_item | ||
|
||
|
||
def remove(self, removed_item): | ||
if removed_item not in self.inventory: | ||
return False | ||
|
||
self.inventory.remove(removed_item) | ||
return removed_item | ||
|
||
|
||
def get_by_category(self, 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. 👍 |
||
items = [] | ||
for item in self.inventory: | ||
if category == item.category: | ||
items.append(item) | ||
return items | ||
|
||
|
||
def swap_items(self, vendor, my_item, their_item): | ||
if my_item not in self.inventory or their_item not in vendor.inventory: | ||
return False | ||
|
||
self.remove(my_item) | ||
vendor.add(my_item) | ||
vendor.remove(their_item) | ||
self.add(their_item) | ||
return True | ||
|
||
|
||
def swap_first_item(self, vendor): | ||
if len(self.inventory) == 0 or len(vendor.inventory) == 0: | ||
return False | ||
|
||
self.inventory[0], vendor.inventory[0] = vendor.inventory[0], self.inventory[0] | ||
return True | ||
|
||
|
||
def get_best_by_category(self, 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. 👍 |
||
items = self.get_by_category(category) | ||
if len(items) == 0: | ||
return None | ||
best_item = '' | ||
best_condition = 0 | ||
for item in items: | ||
if item.condition > best_condition: | ||
best_item = item | ||
best_condition = item.condition | ||
return best_item | ||
|
||
|
||
def swap_best_by_category(self, other, my_priority, their_priority): | ||
my_item_to_swap = self.get_best_by_category(their_priority) | ||
others_item_to_swap = other.get_best_by_category(my_priority) | ||
if my_item_to_swap is None or others_item_to_swap is None: | ||
return False | ||
|
||
self.swap_items(other, my_item_to_swap, others_item_to_swap) | ||
return True |
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.