-
Notifications
You must be signed in to change notification settings - Fork 0
Comments
Conversation
...ограмма не очень аохожа на программу программиста, но я обдумывал это решение до пол 2-го ночи, вроде даже реально похоже на подобие норм программы.
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.
Это норма) Главное уметь искать и понимать, что ты нашел)
src/main/java/Calculator.java
Outdated
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.
Так как у мапы тип ключей String, то вместо Object было бы корректнее сразу написать String
src/main/java/Formatter.java
Outdated
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.
Есть несколько случаев:
- Оканчивается на 1- рубль
- 3-4 - рубля
- 0, 5-9, 11 - 19 - рублей
src/main/java/Main.java
Outdated
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.
Люблю такие комментарии (❁ ́◡`❁)
src/main/java/Main.java
Outdated
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.
Если ввести не интовое значение, то упадет. Нужно либо оборачивать в try-catch, либо проверять ввод через метод scanner.hasNextInt()
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.
Отличный вариант использовать мапу)
src/main/java/Product.java
Outdated
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.
Здесь съехало форматирование, должен быть сдвинут на таб блок. Поможет комбинация ctrl + alt + L или cmd + opt + L
src/main/java/Product.java
Outdated
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.
В русском языке разделитель дробной и целой части запятая, в английском точка. Раз мы общаемся на русском, то можно было оставить запятую)
src/main/java/Product.java
Outdated
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.
Опечаточка в добавить
src/main/java/Product.java
Outdated
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.
Все приходит с опытом) Потом привыкнешь и уже будет у самого глаза болеть от кривого форматирования))
src/main/java/Formatter.java
Outdated
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.
Чтобы проверить правильно окончание, следует посчитать два значения: 1) Последнюю цифру числа - это остаток от деления на 10, то есть price % 10. 2) Последние две цифры - это остаток деления на 100: price % 100.
Далее первым делом надо проверить, входит ли остаток от деления на 100 в диапазон 11-19. Это тот случай, когда будет рублей.
Потом проверяем остаток деления на 10. Если 1 - это рубль (чтобы учесть случаи, когда число кончается на 1: 21, 31, 101 и тд). Если 2-4 - рубля. И остальное будет рублей
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.
про деление по модулю знаю, использовал, тут не стал по невнимательности.
и не учёл про то, что цена может быть больше 19-ти рублей
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.
Да в целом так делают) Если выражение не становится супер сложным и длинным
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.
Ну вообще можно было просто сохранить mod 10, mod 100, а потом в свитч кейсе сначала мод 100 проверить на 11-15, а потом мод 10 на все остальное
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.
Ничесе, я такого варианта еще не встречала в этой работе)) Девушке респект
No description provided.