-
Notifications
You must be signed in to change notification settings - Fork 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
Kunzite - Diana Salazar & Allie Soliz #78
base: main
Are you sure you want to change the base?
Conversation
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.
Good job, Diana and Allie! I've left some suggestions and feedback below in your code!
Things to consider:
- Refactoring the
super().__init__
method so that thecondition
attribute is passed through to the parent constructor to handle. - Combine some of the conditional expressions into compound conditionals to save some lines, so we aren't duplicating the same return statements
import uuid |
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.
Are we creating an instance of uuid
in this file? Doesn't look like it, so we an remove this import!
import uuid |
self.fabric = fabric | ||
self.condition = 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.
the parent class Item
already had a condition
attribute, so let's use that! We don't want to reinvent the wheel if we don't have to!
super().__init__(id,condition)
self.fabric = fabric
|
||
def get_category(self): | ||
return "Clothing" |
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.
This works! But what might happen if the name of this class was suddenly changed? We'd have to remember to change it down here as well. What's one way we could always make sure get_category
will dynamically return the class's name?
|
||
def __str__(self): | ||
return f"An object of type Clothing with id {self.id}. It is made from {self.fabric} fabric." |
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.
Instead of hard coding in the class's name as we did in get_category
above, how could we refactor this in order to use get_category
instead?
import uuid |
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.
import uuid |
my_item = self.inventory[0] | ||
a = self.swap_items(other_vendor, my_item, their_item) | ||
|
||
return a |
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.
This works fine! If we wanna get wild, we can combine these all into one line:
return self.swap_items(other_vendor, self.inventory[0], other_vendor.inventory[0])
return a | ||
|
||
def get_by_category(self, category): |
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.
👍
|
||
def get_best_by_category(self, category): | ||
|
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.
return list_of_objects | ||
|
||
def get_best_by_category(self, category): |
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.
👍
return False | ||
if not their_best_item: | ||
return False |
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.
Let's combine these!
No description provided.