forked from AdaGold/swap-meet
-
Notifications
You must be signed in to change notification settings - Fork 71
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
Scissors - Maria M. #53
Open
maria-im015
wants to merge
4
commits into
Ada-C15:master
Choose a base branch
from
maria-im015: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
4 commits
Select commit
Hold shift + click to select a range
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,11 @@ | ||
#Wave 5 | ||
|
||
from swap_meet.item import Item | ||
|
||
class Clothing(Item): | ||
|
||
def __init__(self, condition=0): | ||
Item.__init__(self, "Clothing", condition=condition) | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#Wave 5 | ||
|
||
from swap_meet.item import Item | ||
|
||
class Decor(Item): | ||
|
||
def __init__(self, condition=0): | ||
Item.__init__(self, "Decor", condition=condition) | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#Wave 5 | ||
|
||
from swap_meet.item import Item | ||
|
||
class Electronics(Item): | ||
|
||
def __init__(self, condition=0): | ||
Item.__init__(self, "Electronics", condition=condition) | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#Wave 2 | ||
class Item: | ||
def __init__(self, category = "", condition=0,): | ||
self.category = category | ||
self.condition = condition | ||
|
||
def __str__(self): | ||
return "Hello World!" | ||
|
||
#Wave 5 | ||
def condition_description(self): | ||
condition = self.condition | ||
if condition >= 4.0: | ||
return (f"The condition rating of this item is a {condition}, it's almost new") | ||
elif condition >= 3.0: | ||
return (f"The condition rating of this item is a {condition}, it's in good condition and gently used.") | ||
elif condition >= 2.0: | ||
return (f"The condition rating of this item is a {condition}, it's in fair condition and has cosmetic flaws and signs of use.") | ||
else: | ||
return (f"The condition rating of this item is a {condition}, it's in poor condition and has some major cosmetic flaws.") | ||
|
||
|
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,79 @@ | ||
from swap_meet.item import Item | ||
from swap_meet.clothing import Clothing | ||
from swap_meet.decor import Decor | ||
from swap_meet.electronics import Electronics | ||
|
||
#Wave 1 | ||
class Vendor: | ||
def __init__(self, inventory = None): | ||
if inventory is None: | ||
self.inventory = [] | ||
else: | ||
self.inventory = inventory | ||
|
||
def add(self, new_item): | ||
self.inventory.append(new_item) | ||
return new_item | ||
|
||
def remove(self, remove_item): | ||
if remove_item not in self.inventory: | ||
return False | ||
else: | ||
self.inventory.remove(remove_item) | ||
return remove_item | ||
|
||
#Wave 2 | ||
def get_by_category(self, category): | ||
category_list = [] | ||
for item in self.inventory: | ||
if item.category == category: | ||
category_list.append(item) | ||
return category_list | ||
|
||
#Wave 3 | ||
def swap_items(self, friend, my_item, their_item): | ||
if my_item not in self.inventory or \ | ||
their_item not in friend.inventory: | ||
return False | ||
|
||
self.remove(my_item) | ||
friend.add(my_item) | ||
friend.remove(their_item) | ||
self.add(their_item) | ||
return True | ||
|
||
#Wave 4 | ||
def swap_first_item(self, friend): | ||
if len(self.inventory) < 1 or \ | ||
len(friend.inventory) < 1: | ||
return False | ||
|
||
my_first_item = self.inventory[0] | ||
their_first_item = friend.inventory[0] | ||
|
||
self.swap_items(friend, my_first_item, their_first_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. Great use of the existing method! |
||
return True | ||
|
||
|
||
#Wave 6 | ||
def get_best_by_category(self, category): | ||
best_item = None | ||
best_item_condition = -1 | ||
for item in self.inventory: | ||
if item.category == category: | ||
if item.condition > best_item_condition: | ||
best_item = item | ||
best_item_condition = item.condition | ||
return best_item | ||
|
||
def swap_best_by_category(self, other, my_priority, their_priority): | ||
|
||
my_best_item = self.get_best_by_category(their_priority) | ||
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 use of the existing method! |
||
if my_best_item == None: | ||
return False | ||
|
||
their_best_item = other.get_best_by_category(my_priority) | ||
if their_best_item == None: | ||
return False | ||
|
||
return self.swap_items(other, my_best_item, their_best_item) |
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 use of existing methods!