Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Kirill Kostin #11

wants to merge 2 commits into from

Conversation

konmedoed
Copy link

No description provided.

}
console.log(summCal);
}
Order.prototype.payForOrder = function(){

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){
Copy link

@Aniuta907 Aniuta907 Feb 25, 2022

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;

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')

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(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Функции с названием getPrice, getCalories просто повторяются в классах различных типов еды. По итогу нет общего предка (например, Item или Product), от которого наследовались бы гамбургер, салат и напиток.
Предлагаю создать общего предка и отнаследоваться

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants