forked from AdaGold/swap-meet
-
Notifications
You must be signed in to change notification settings - Fork 110
Cheetahs - Tami Adetayo #103
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
tamiade
wants to merge
8
commits into
Ada-C18:master
Choose a base branch
from
tamiade: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
8 commits
Select commit
Hold shift + click to select a range
1475bd3
Completed Wave 1 & 2 functions
tamiade 9b13935
Pass None into Vendor __init__ method instead of mutable empty list
tamiade c0bd9c4
Completed tests for wave 1 & 2
tamiade f9b1cc8
Completed wave 3 method
tamiade 05b032d
Finished wave 4 method
tamiade 8f08fab
Completed wave 5 method
tamiade 97d4046
Finished wave 6 method and dried up code
tamiade 2d805e0
Ran integration tests
tamiade 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,9 @@ | ||
| class Clothing: | ||
| pass | ||
| from swap_meet.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,9 @@ | ||
| class Decor: | ||
| pass | ||
| from swap_meet.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,10 @@ | ||
| class Electronics: | ||
| pass | ||
| from swap_meet.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,22 @@ | ||
| 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 == 0: | ||
| return "Heavily used!" | ||
| elif self.condition == 1: | ||
| return "Fairly used!" | ||
| elif self.condition == 2: | ||
| return "Barely used!" | ||
| elif self.condition == 3: | ||
| return "Like new!" | ||
| elif self.condition == 4: | ||
| return "Great condition!" | ||
| else: | ||
| return "Excellent condition!" | ||
|
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 job with your |
||
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,59 @@ | ||
| class Vendor: | ||
| pass | ||
|
|
||
| def __init__(self, inventory=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: | ||
|
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. This approach works, but consider how a |
||
| self.inventory.remove(item) | ||
| return item | ||
| return False | ||
|
|
||
| def get_by_category(self, category): | ||
| items = [] | ||
| for item in self.inventory: | ||
| if item.category == category: | ||
| items.append(item) | ||
| return items | ||
|
|
||
| def swap_items(self, vendor, my_item, their_item): | ||
| if their_item not in vendor.inventory or my_item not in self.inventory: | ||
| return False | ||
|
|
||
| self.remove(my_item) | ||
| self.add(their_item) | ||
| vendor.remove(their_item) | ||
| vendor.add(my_item) | ||
| return True | ||
|
|
||
| def swap_first_item(self, vendor): | ||
| if not self.inventory or not vendor.inventory: | ||
| return False | ||
|
|
||
| instance_first_item = self.inventory[0] | ||
| vendor_first_item = vendor.inventory[0] | ||
| return self.swap_items(vendor, instance_first_item, vendor_first_item) | ||
|
|
||
| def get_best_by_category(self, category_str): | ||
| highest_item_pair = (-1.0, None) | ||
| for item in self.inventory: | ||
| if item.category == category_str and item.condition > highest_item_pair[0]: | ||
| highest_item_pair = (item.condition, item) | ||
| return highest_item_pair[1] | ||
|
|
||
| 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) | ||
| if my_best is None or their_best is None: | ||
| return False | ||
| return self.swap_items(other, my_best, their_best) | ||
|
|
||
|
|
||
|
|
||
|
|
||
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 job with wave 5 and using inheritance! Nice work hardcoding the category too 🥳