-
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- Terah #72
base: master
Are you sure you want to change the base?
Scissors- Terah #72
Conversation
… and clean up code
def __init__(self, condition = 0): | ||
self.category = "Decor" | ||
self.condition = float(condition) |
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.
Another way to write this is to use super to take advantage of the code in Item's constructor:
def __init__(self, condition = 0):
super().__init__("Decor", condition)
self.condition = float(condition) | ||
|
||
def __str__(self): | ||
if str(Item): |
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.
str(Item)
evaluates to something like: <class 'main.Item'> so under the Python 'truthy' rules this will always evaluate to True.
if self.condition in range(0,1): | ||
return "it's kinda like when you take stuff to goodwill even when you know it should go in the trash but you just don't have the heart" | ||
elif self.condition in range(1,2): | ||
return "you're never going to have the time to fix it in the way you envision, it's going to sit in yr garage for 3 years and yr gonna get rid of it in some spring cleaning purge" | ||
elif self.condition in range (2,3): | ||
return "it's alright, but probably won't last much longer" | ||
elif self.condition in range (3,4): | ||
return "it is what it is!" | ||
elif self.condition in range (4,5): | ||
return "is a good find and the only reason you should pass is cuz you know you don't need another and someone else shouls have the opportunity" |
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.
I don't think range() is doing what you want it to do here. Range returns a sequence of integers from the first integer up to but not including the second integer. Consider these two code snippets:
if 5 in range(1, 6):
print("5 in the range")
if 4.5 in range(1, 6):
print("4.5 in the range")
The first snippet will print '5 in the range' but the second will not print anything. I think what you are trying to do is this:
if self.condition >= 0 and self.condition > 1:
return "it's kinda like when you take stuff to goodwill even when you know it should go in the trash but you just don't have the heart"
elif self.condition >=1 and self.condition < 2:
...
self.remove(my_item) | ||
vendor.remove(their_item) | ||
self.add(their_item) | ||
vendor.add(my_item) |
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 code re-use!
self.remove(my_item) | ||
vendor.remove(their_item) | ||
self.add(their_item) | ||
vendor.add(my_item) |
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.
How could you use swap_items
here to DRY up your code?
they_want = self.get_best_by_category(their_priority) | ||
my_want = other.get_best_by_category(my_priority) | ||
|
||
self.swap_items(other, they_want, my_want) |
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 helper functions!
Great work on this project! I have a few minor comments about places that you can DRY up your code, but overall this is a very solid & clean project. |
OOPS, lost track of time this morning!