Open
Conversation
…e_01 and test_wave_02 pass
…t_category() and __str__() methods. They all are child classes of item.py. Implemented condition_description in item.py. All tests in test_wave_05.py are passing.
…y() in vendor.py. Reversed the condition descriptions in item.py. All tests in test_wave_06.py are passing.
…ms() methods in vendor.py. All tests in test_wave_07.py are passing. All integration testes are passing
…ion_description()
| class Decor(Item): | ||
| def __init__(self, id=None, width=0, length=0, condition=0): | ||
| super().__init__(id, condition) | ||
| self.width = width if width else 0 |
| def __str__(self): | ||
| return f"An object of type {self.get_category()} with id {self.id}" | ||
|
|
||
| def condition_description(self): |
There was a problem hiding this comment.
Well organized code! At this point, you might see that a dict could be an alternative. And, has O(1) lookup time. In the worse case, it would take O(n) -- for n conditions -- to fall through to the last condition case with the if/else structure. :)
| def __init__(self, inventory=None): | ||
| self.inventory = inventory if inventory else [] | ||
|
|
||
| if not isinstance(self.inventory, list): |
| def get_by_id(self, id): | ||
| if not id or not self.inventory: | ||
| return None | ||
| return next((item for item in self.inventory if item.id == id), None) |
| return True | ||
|
|
||
| def swap_first_item(self, other_vendor): | ||
| if not self or not other_vendor: |
There was a problem hiding this comment.
nice example of guard statements. No need to indent the rest of the function as an else block after the returns. Clean.
| category_items = self.get_by_category(category) | ||
| if not category_items: | ||
| return None | ||
| return max(category_items, key=lambda item: item.condition) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.