-
Notifications
You must be signed in to change notification settings - Fork 220
Comments
Пишем консольное приложение#118
Conversation
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.
Math.floor(price) считается 3 раза, можно посчитать 1 раз и записать в переменную
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 " <нужное слово>";. Или оставить переменную, но убрать здесь инициализацию, в каждом if убрать return, оставить только присваивание переменной нужного слова, а после всех if-else поставить return roubleCase;
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 Math.floor(price) % 100, то для 111, 211 и т.д. будет работать тоже
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 можно в этом классе убрать, а при вызове метода calculate в Main сначала создавать объект класса Item. Подробнее про 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.
Можно результатом этого метода возвращать посчитанную sum, тогда не надо будет её использовать в 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.
Можно этот вывод вынести до while, тогда он будет печататься один раз, в принципе этого достаточно для пользователя
Добрый день! Задание по спринту 2.