-
Notifications
You must be signed in to change notification settings - Fork 220
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() или try-catch
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.
Это не очень информативное название для переменной, коллегам придётся вникать, для чего она используется. Лучше задать понятное имя, например, personCount
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.
Такие отладочные выводы можно делать для себя, но при сдаче работы лучше их закомментировать, всё-таки в реальном приложении такие вещи пользователям попадать не должны
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.
Видно, что местами не хватает отступов или пробелов (в условиях выше, например), ты можешь применить в студии автоформатирование (в выбранном файле, сверху вкладка Code - Reformat Code, либо Ctrl+Alt+L), тогда автоматически код выправится.
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.
sum1%10 повторяется несколько раз, можно вынести в переменную и сравнивать уже с ней
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.
Условие можно заменить на !pos.equalsIgnoreCase("завершить"), это будет то же самое. ! - это "not" оператор
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.
Если ввести число в формате 10.45, приложение упадет. А вот ввод через запятую принимает. Можно разобраться, почему так происходит, и в любом случае обработать возможную ситуацию, когда введена строка вместо числа, чтобы приложение не падало
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.
Не очень информативные названия для переменных, коллегам будет трудно понимать. И sum1 используется только в методе totalSum, можно туда и перенести её.
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.println(String.format(message,sum/persons) + <...>); повторяется, его можно вынести вниз, после if-else, оставив в проверке только определение слово рубль
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.
Если сумма будет оканчиваться на 5, окончание будет "рубля" вместо "рублей". Потому что условие здесь должно быть &&, то есть "и", а не || ("или"). Сейчас сначала идет проверка, что число >=2, если так и есть, то входим в первую ветку, а должна быть ещё проверка, что число <=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.
имелось ввиду не написать комментарии к переменным, а дать новое имя, которые лучше бы отражало суть переменной, например sumAllGoods
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.
так же здесь не понятно что такое sum1 и что в ней храниться
My first try at Java