-
Notifications
You must be signed in to change notification settings - Fork 590
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 - Masha & Soleil #24
Open
mariia-iureva
wants to merge
26
commits into
AdaGold:main
Choose a base branch
from
mariia-iureva:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a2899e7
added add method and remove method
soleilherring f3ba8e8
unskipped tests
soleilherring 00ee0b4
Changes for wave 2, 1 test is not working yet
mariia-iureva 8433589
Added assert to the last test of wave 2
mariia-iureva 0d6d6bc
Added functions to wave 3, 4, and 5
soleilherring dfffc28
Wave 6 first attempt
soleilherring eb9f4e0
Wave 6 second attempt
soleilherring 6e37649
wave 6 updated get best category function
soleilherring 746e5a2
Wave 6 second function
mariia-iureva c8383f7
playing around with tests
soleilherring 4958922
adding playtester
mariia-iureva 76d828e
modified play tester and wave 6
soleilherring be4eeb6
fixed original function for swap_best_by_category
soleilherring 8f535d7
created assertions for wave 6
soleilherring f87c744
tested integration test
soleilherring 43d90c1
tested again for integration test
soleilherring e436df2
changed item to include dictionary instead of if statements
soleilherring 738ada4
changed item to include dictionary deleted if statment
soleilherring 1385620
Some refactoring on Wave 6 and drying the code
mariia-iureva ef67a75
refactored get best by category
soleilherring 8a4984e
Refactored vendor.py, removed excessive else statements
mariia-iureva 8822bd8
updated wave 6 tests
soleilherring fe0bbdb
Added tests for Wave 7, added possible age functions intovendor
mariia-iureva 43386ae
Merge branch 'master' of https://github.com/mariia-iureva/swap-meet
mariia-iureva 21fdb1e
added more tests to wave 6
soleilherring b0df797
finished wave 7 created get_newest function and revised tests
soleilherring File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
from swap_meet.vendor import Vendor | ||
from swap_meet.clothing import Clothing | ||
from swap_meet.decor import Decor | ||
from swap_meet.electronics import Electronics | ||
|
||
#def test_swap_best_by_category(): | ||
# Arrange | ||
# me | ||
item_a = Decor(condition=2.0) | ||
item_b = Electronics(condition=4.0) | ||
item_c = Decor(condition=4.0) | ||
tai = Vendor( | ||
inventory=[item_a, item_b, item_c] | ||
) | ||
|
||
# them | ||
item_d = Clothing(condition=2.0) | ||
item_e = Decor(condition=4.0) | ||
item_f = Clothing(condition=4.0) | ||
jesse = Vendor( | ||
inventory=[item_d, item_e, item_f] | ||
) | ||
|
||
# Act | ||
result = tai.swap_best_by_category( | ||
other=jesse, | ||
my_priority="Clothing", | ||
their_priority="Decor" | ||
) | ||
# print(tai.inventory) | ||
# print(jesse.inventory) | ||
#print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, age = 0): | ||
super().__init__(category = "Clothing", condition = condition, age = age) | ||
|
||
|
||
def __str__(self): | ||
return "The finest clothing you could wear." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, age = 0): | ||
super().__init__(category = "Decor", condition = condition, age = age) | ||
|
||
def __str__(self): | ||
return "Something to decorate your space." | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
class Electronics: | ||
pass | ||
from swap_meet.item import Item | ||
|
||
class Electronics(Item): | ||
def __init__(self, condition = 0, age = 0): | ||
super().__init__(category = "Electronics", condition = condition, age = age) | ||
|
||
|
||
def __str__(self): | ||
return "A gadget full of buttons and secrets." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# from swap_meet.vendor import Vendor | ||
|
||
class Item: | ||
pass | ||
|
||
def __init__(self, category = None, condition = 0, age = 0): | ||
self.category = category if category is not None else "" | ||
self.condition = condition | ||
self.age = age | ||
|
||
def __str__(self): | ||
return "Hello World!" | ||
|
||
def condition_description(self): | ||
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. Nice 👍 |
||
self.condition = round(self.condition) | ||
condition_dict = { | ||
0 : "garbage", | ||
1 : "bad", | ||
2 : "used", | ||
3 : "lightly used", | ||
4 : "like new", | ||
5 : "new" | ||
} | ||
return condition_dict[self.condition] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,107 @@ | ||
from swap_meet.item import Item | ||
|
||
class Vendor: | ||
pass | ||
def __init__(self, inventory=None): | ||
self.inventory = inventory if inventory is not None else [] | ||
|
||
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): | ||
list_of_items = [] | ||
for item in self.inventory: | ||
if item.category == category: | ||
list_of_items.append(item) | ||
|
||
return list_of_items | ||
|
||
def swap_items(self, other_vendor, my_item, their_item): | ||
if my_item not in self.inventory or their_item not in other_vendor.inventory: | ||
return False | ||
|
||
other_vendor.remove(their_item) | ||
self.add(their_item) | ||
self.remove(my_item) | ||
other_vendor.add(my_item) | ||
return True | ||
|
||
def swap_first_item(self, other_vendor): | ||
if not self.inventory or not other_vendor.inventory: | ||
return False | ||
|
||
my_item = self.inventory[0] | ||
their_item = other_vendor.inventory[0] | ||
self.swap_items(other_vendor, my_item, their_item) | ||
return True | ||
|
||
def get_best_by_category(self, category): | ||
items_with_category = self.get_by_category(category) | ||
if not items_with_category: | ||
return None | ||
|
||
max_item_condition = max(items_with_category, key=lambda item: item.condition) | ||
return max_item_condition | ||
|
||
|
||
def swap_best_by_category(self, other, my_priority, their_priority): | ||
my_best_by_category = self.get_best_by_category(their_priority) | ||
their_best_by_category = other.get_best_by_category(my_priority) | ||
|
||
if not my_best_by_category or not their_best_by_category: | ||
return False | ||
|
||
result = self.swap_items(other, my_best_by_category, their_best_by_category) | ||
return result | ||
|
||
def get_newest(self, any_list=None): | ||
# any_list = self.inventory if self.inventory is not None else [] | ||
# other version # | ||
if any_list is None: | ||
any_list = self.inventory | ||
|
||
if not self.inventory or not any_list: | ||
return None | ||
|
||
return min(any_list, key=lambda item: item.age) | ||
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. Nice use of a lambda! |
||
|
||
|
||
def get_newest_by_category(self, category): | ||
newest_items_with_category = self.get_by_category(category) | ||
if not newest_items_with_category: | ||
return None | ||
|
||
newest_item = self.get_newest(newest_items_with_category) | ||
return newest_item | ||
|
||
|
||
def swap_newest(self, other): | ||
my_newest_item = self.get_newest() | ||
other_newest_item = other.get_newest() | ||
if not my_newest_item or not other_newest_item: | ||
return False | ||
|
||
self.swap_items(other, my_newest_item, other_newest_item) | ||
return True | ||
|
||
|
||
|
||
def swap_newest_by_category(self, other, my_priority=None, their_priority=None): | ||
my_newest_by_category = self.get_newest_by_category(their_priority) | ||
their_newest_by_category = other.get_newest_by_category(my_priority) | ||
if not my_newest_by_category or not their_newest_by_category: | ||
return False | ||
|
||
self.swap_items(other, my_newest_by_category, their_newest_by_category) | ||
return True | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This probably doesn't need to be committed.