-
Notifications
You must be signed in to change notification settings - Fork 13
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
Kirill Kostin #11
base: main
Are you sure you want to change the base?
Kirill Kostin #11
Conversation
} | ||
console.log(summCal); | ||
} | ||
Order.prototype.payForOrder = function(){ |
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.drink = []; | ||
} | ||
|
||
Order.prototype.addHamburger = function(size, toping){ |
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 this.salad.calories*this.weight/100; | ||
} | ||
getPrice(){ | ||
return this.salad.price*this.weight/100; |
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.
100 в данном случае магическое число, его лучше вынести в константу
price: 15, | ||
calories: 10, | ||
} | ||
if (stuffing.toLowerCase()=='cheese') |
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.
Для читабельности можно попробовать переписать if-else на switch-case
return 0; | ||
} | ||
} | ||
getCalories(){ |
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.
Функции с названием getPrice, getCalories просто повторяются в классах различных типов еды. По итогу нет общего предка (например, Item или Product), от которого наследовались бы гамбургер, салат и напиток.
Предлагаю создать общего предка и отнаследоваться
No description provided.