-
Notifications
You must be signed in to change notification settings - Fork 0
Comments
Conversation
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.
У Scanner есть удобный метод hasNextInt, можно сразу узнать без дополнительных проверок возможно ли интерпретировать строку как int
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/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.
В таких случаях для вывода лучше использовать System.out.printf, ему можно передать параметры, которые будут поставлены в строку.
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.
Немного некорректно рассчитывается окончание. Получается если цена будет 14 рублей, метод вернет рубля. Правильный алгоритм звучит так - Округлить double до целых, проверить лежит ли остаток от деления на 100 в интервале от 11 до 14 включительно, если да, то окончание "рублей", если нет, то берем остаток от деления на 10 и проверяем: если 1 - рубль, если 2-4 - рубля, остальные случаи - рублей. То есть нужно во-первых проверять именно остаток от деления, во-вторых учесть, что числа заканчивающиеся на 11-12-13-14 и заканчивающиеся на 1-2-3-4, будут иметь разные окончания
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.
Можно посчитать это значение один раз - при выводе значения в getPriceForOnePeople
-deleted fun onDestroy(). -in fun addProduct() change return String to String.format(). -changed the calculation of the endings of the word "рубль". -the variable "priceForOnePeople" is counted once
No description provided.