-
Notifications
You must be signed in to change notification settings - Fork 589
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 - Melley Gebretatios and QP #22
Open
mell2022
wants to merge
23
commits into
AdaGold:main
Choose a base branch
from
mell2022: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
23 commits
Select commit
Hold shift + click to select a range
97f9ff4
pass test wave 1
mell2022 fd4c094
commited out skip on test wave 1
20b4c50
commiting vendor.py
e34b241
Merge branch 'master' of https://github.com/mell2022/swap-meet
0440e36
tests pass wave 2, adde d vendor method and item attribute.
mell2022 c484fb5
item and test_wave 2 changes
442f863
item vendor and test_wave2 merged
9a67a4b
Wave 3 all tests pass and added swap items to vendor.py and stringify.
mell2022 1f52e52
updated wave_3
c952e39
solved merged conflicts
f0fe840
Test wave 4 pass addedd first swap item.
mell2022 1920965
modified wave_4
ffe18db
Merge branch 'master' of https://github.com/mell2022/swap-meet
be3ef09
completed clothing, decor, elecronics, item, integration tests 1-3 p…
9cddf46
started wave_6 for vendor.py
32f10f8
All tests pass in wave 5.
mell2022 ec2327a
finished: clothing,decor,electronis child classes, vendor wave 5,all …
0378b22
pseudocode for both wave_6 methods, created helper_method to get best…
a63fd96
changed item condition dict to list, started wave6, unskipped tests w…
3ab563f
completed get_best_by_category wave 6, updated item.py, unskipped tes…
825392c
Part of wave 6 done
mell2022 d2cc000
modified wave 6: vendor method and test
c90149a
all unit tests and integration tests completed and pass, finished ven…
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 |
---|---|---|
@@ -1,2 +1,11 @@ | ||
class Clothing: | ||
pass | ||
from swap_meet.item import Item | ||
class Clothing(Item): | ||
|
||
# instantiate a class: this is where __init__ and attributes go | ||
def __init__(self, condition=0): | ||
super().__init__(category="Clothing", condition=condition) | ||
|
||
def __str__(self): | ||
return f"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,11 @@ | ||
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 f"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): | ||
super().__init__(category="Electronics", condition=condition) | ||
|
||
def __str__(self): | ||
return f"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,19 @@ | ||
class Item: | ||
pass | ||
|
||
def __init__(self, category="", condition=0): | ||
self.category = category | ||
self.condition = condition | ||
|
||
def __str__(self): | ||
return f"Hello World!" | ||
|
||
def condition_description(self): | ||
conditions = { | ||
0: "You don't want this.", | ||
1: "Anything is cheap enough.", | ||
2: "It's OK.", | ||
3: "No major issues.", | ||
4: "Hardly worn and well taken care of.", | ||
5: "Gonna go fast!" | ||
} | ||
return f"{conditions[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,77 @@ | ||
from nis import cat | ||
|
||
|
||
class Vendor: | ||
pass | ||
def __init__(self, inventory=None): | ||
inventory = inventory if inventory is not None else [] | ||
self.inventory = inventory | ||
|
||
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 | ||
else: | ||
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_friend, my_item, their_item): | ||
if my_item not in self.inventory or their_item not in vendor_friend.inventory: | ||
return False | ||
|
||
self.inventory.remove(my_item) | ||
vendor_friend.inventory.append(my_item) | ||
|
||
vendor_friend.inventory.remove(their_item) | ||
self.inventory.append(their_item) | ||
return True | ||
|
||
def swap_first_item(self, vendor_friend): | ||
if self.inventory == [] or vendor_friend.inventory == []: | ||
return False | ||
|
||
my_first_item = self.inventory[0] | ||
their_first_item = vendor_friend.inventory[0] | ||
|
||
self.inventory.remove(my_first_item) | ||
self.inventory.append(their_first_item) | ||
|
||
vendor_friend.inventory.remove(their_first_item) | ||
vendor_friend.inventory.append(my_first_item) | ||
|
||
return True | ||
|
||
# WAVE 6 | ||
def get_best_by_category(self, category): | ||
list_of_items = self.get_by_category(category) | ||
if not list_of_items: | ||
return None | ||
else: | ||
best_item = max(list_of_items, key = lambda item: item.condition) | ||
|
||
return best_item | ||
|
||
def swap_best_by_category(self, other, my_priority, their_priority): | ||
if not self.inventory or not other.inventory: | ||
return False | ||
|
||
their_priority_item = other.get_best_by_category(my_priority) | ||
if not their_priority_item: | ||
return False | ||
|
||
my_priority_item = self.get_best_by_category(their_priority) | ||
if not my_priority_item: | ||
return False | ||
|
||
return self.swap_items(other, my_priority_item, their_priority_item) |
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
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.
Nice use of the lambda here!