forked from AdaGold/swap-meet
-
Notifications
You must be signed in to change notification settings - Fork 110
Tigers Rose + Reyna #89
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
Open
reynamdiaz
wants to merge
11
commits into
Ada-C18:master
Choose a base branch
from
reynamdiaz:master
base: master
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
11 commits
Select commit
Hold shift + click to select a range
a223f3e
"initiated class, added add() and remove() functs"
reynamdiaz 7a0d048
"initiated Item class added get_by_category funct"
reynamdiaz 8713d13
completed test and implementation of wave_03
rose-codes 384ccff
Began tests for integration tests
rose-codes 2e6ef48
"integrated test01/02/03 passing"
reynamdiaz 371c842
implemented wave_04 and passed unit tests
rose-codes f9462ee
implemented wave_05 and passed unit tests
rose-codes c2fe4d2
"wave05 passing"
reynamdiaz 53dd2ae
"added get_best_by_category funct, test pass"
reynamdiaz b4a2521
"added swap_best... funct, all tests passing"
reynamdiaz 08a3a6a
"refactored wave05"
reynamdiaz 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 hidden or 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,8 @@ | ||
| class Clothing: | ||
| pass | ||
| from .item import Item | ||
| class Clothing(Item): | ||
| def __init__(self, condition=0): | ||
| super().__init__("Clothing", condition) | ||
|
|
||
|
|
||
| def __str__(self): | ||
| return "The finest clothing you could wear." |
This file contains hidden or 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,8 @@ | ||
| class Decor: | ||
| pass | ||
| from .item import Item | ||
| class Decor(Item): | ||
| def __init__(self, condition=0): | ||
| super().__init__("Decor", condition) | ||
|
|
||
|
|
||
| def __str__(self): | ||
| return "Something to decorate your space." |
This file contains hidden or 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,8 @@ | ||
| class Electronics: | ||
| pass | ||
| from .item import Item | ||
| class Electronics(Item): | ||
| def __init__(self, condition=0): | ||
| super().__init__("Electronics", condition) | ||
|
|
||
|
|
||
| def __str__(self): | ||
| return "A gadget full of buttons and secrets." |
This file contains hidden or 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,19 @@ | ||
| 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): | ||
| if self.condition == 5: | ||
| return "This is probably out of your price range normally" | ||
| elif self.condition >= 4: | ||
| return "This is still pretty good, just not mint." | ||
| elif self.condition >= 3: | ||
| return "This isn't bad, could be better." | ||
| elif self.condition >= 2: | ||
| return "Not the best, you could live without it." | ||
| elif self.condition > 0: | ||
| return "Put this down and walk away." |
This file contains hidden or 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,58 @@ | ||
| from unittest.mock import NonCallableMagicMock | ||
|
|
||
|
|
||
| class Vendor: | ||
| pass | ||
| 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 not item in self.inventory: | ||
| return False | ||
| self.inventory.remove(item) | ||
| return item | ||
|
|
||
| def get_by_category(self, category): | ||
| items_list = [] | ||
| for item in self.inventory: | ||
| if getattr(item, 'category') == category: | ||
| items_list.append(item) | ||
| return items_list | ||
|
|
||
| def swap_items(self, vendor1, my_item, their_item): | ||
| if my_item not in self.inventory or their_item not in vendor1.inventory: | ||
| return False | ||
| self.remove(my_item) | ||
| vendor1.add(my_item) | ||
| vendor1.remove(their_item) | ||
| self.add(their_item) | ||
| return True | ||
|
|
||
| def swap_first_item(self, vendor1): | ||
| if len(self.inventory) == 0 or len(vendor1.inventory) == 0: | ||
| return False | ||
| return self.swap_items(vendor1, self.inventory[0], vendor1.inventory[0]) | ||
|
|
||
| def get_best_by_category(self, category): | ||
| best_item_by_category = 0 | ||
| best_item = None | ||
| for item in self.inventory: | ||
| if item.category == category: | ||
| if item.condition > best_item_by_category: | ||
| best_item_by_category = item.condition | ||
| best_item = item | ||
| return best_item | ||
|
|
||
| def swap_best_by_category(self, other, my_priority, their_priority): | ||
| my_best = self.get_best_by_category(their_priority) | ||
| their_best = other.get_best_by_category(my_priority) | ||
|
Comment on lines
+53
to
+54
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. Great reuse of existing functions |
||
| if my_best == None or their_best == None: | ||
| return False | ||
| self.swap_items(other, my_best, their_best) | ||
| return True | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Great reusable method