-
Notifications
You must be signed in to change notification settings - Fork 21
Ocelots - Larissa A. #4
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
base: main
Are you sure you want to change the base?
Conversation
…r by area, clothing by fabric, electronics by type)
| @@ -1,0 +1,8 @@ | |||
| conditions = { | |||
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 dict for this! O(1) lookup vs worst case O(n) for n conditions for an if/else to fall through to the last condition!
| def check_valid_id(self, id): | ||
| if type(id) == int: | ||
| return id | ||
| elif str(id).isnumeric(): |
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 type conversation attempt with error checking!
| - (obj) item with id or None | ||
| """ | ||
| result = list(filter(lambda item: item.id == id, self.inventory)) |
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 lambda with filter here!
|
|
||
| def swap_items(self, other_vendor, my_item, their_item): | ||
| """ | ||
| Swaps two indicated items between vendors. |
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.
useful, clear comments!
| their_item not in other_vendor.inventory): | ||
| return False | ||
| else: | ||
| self.remove(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.
well done making use of existing vendor functions, rather than reimplementing the logic here
| :returns: | ||
| - (bool) True if swapped or False | ||
| """ | ||
| [vendor.display_inventory(category) for vendor in [self, other_vendor]] |
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 list comprehension :)
|
|
||
| # ~~~~~ swap_by_category_attribute Tests ~~~~~ | ||
| # ~~~~~ swap decor by area Tests ~~~~~ | ||
| def test_swap__when_no_matching_area_returns_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.
nice extra testing :)
No description provided.