-
Notifications
You must be signed in to change notification settings - Fork 0
Homework 2 #3
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: master
Are you sure you want to change the base?
Homework 2 #3
Conversation
shorodilov
left a comment
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.
Потребує виправлень
01/task_01.py
Outdated
| return self.name | ||
|
|
||
| def __eq__(self, other): | ||
| return self.name == other.name and self.price == other.price |
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.
Додай перевірку типів. Бо це спрацює лише для порівняння з об'єктом Product.
01/task_01.py
Outdated
| other.products_list.index(product) | ||
| ] | ||
| self.add_product(product, count) | ||
| return self |
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.
Тут ліпше створити новий об'єкт кошика і повертати його.
01/task_01.py
Outdated
| """Adding products to the cart""" | ||
|
|
||
| if product in self.products_list: | ||
| self.products_count[ |
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.
Ліпше розбивай таке на декілька рядків, або слідуй PEP-8.
Тут все вірно, але у мене очі слізяться коли таке бачу.
01/task_01.py
Outdated
| if isinstance(other, Product): | ||
| self.add_product(other, 1) | ||
| elif isinstance(other, ShoppingCart): | ||
| for product in other.products_list: |
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.
Он же ж тип нормально використовуєш zip ніжче...
|
Додав перевірку типів в eq. Створив новий об'єкт кошику. Додав окремо рядок для індексу. Змінив на zip в add. |
shorodilov
left a comment
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.
lgtm
Adding magic methods concerning hometask