-
Notifications
You must be signed in to change notification settings - Fork 220
Comments
Conversation
AugustIva
commented
Nov 1, 2022
Проверочный комментарий
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.
Abstract у Main можно убрать. Дальше по курсу будет рассказано, что это такое, но пока не нужно
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.
Можно убрать все модификаторы static, а при вызове методов в main создавать экземпляр класса ProductsList , и вызывать методы у него. Дальше по курсу будет рассказано, для чего static нужен
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.
Студия подсказывает, что возвращаемый тип метода не используется. Можно либо сделать метод void, либо использовать возвращаемый результат
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.
Метод можно сделать приватным, поскольку он используется только внутри этого класса
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.
Лучше назвать списки очевиднее, productList или products и priceList или prices
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 или Food, с полями name и price, и использовать его для записи каждого кушанья. Тогда вместо двух списков понадобится один список кушаний ArrayList<Food>
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.
Лучше сделать метод void вместо возвращаемого типа Double, и эта строчка будет не нужна
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.
Поскольку ты проверяешь здесь результат деления по модулю 10 (%10), он не может быть больше 9, поэтому часть с ending <= 20 всегда будет true. Лучше здесь поставить default, а для проверки, что число у нас между 11 и 19, добавить перед этим if-else один с условием, что (int)sum % 100 >= 11 и <= 19
No description provided.