-
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.
По хорошему надо выносить всю логику из класса 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.
Исправил
src/main/java/Formater.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.
private
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.
numberOfPeople, listOfProducts и costOfProducts - final
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.
Исправил
Amicratus
commented
Jan 9, 2024
Вынес из main все действия. Оставил только создание класса Calcualtor и его метод void start(), который запускает программу.
Так же доработал метод checkRes(double) в классе Formater. До этого программа неправильно выводило слово для чисел оканчивающихся на 11-14.
Добавил класс Calculator, в котором хранятся общая цена, количество людей, список товаров и список их цен:
double totalCost, int numberOfPeople, ArrayList listOfProducts, ArrayList costOfProducts.
Записан метод show(), который выводит все товары и итоговую сумму, которую должен оплатить каждый из людей.
Методы addProduct() и addProductCost() записывают название продукта и его цену соответственно.
Добавлен так же класс Formater с методами scanInt(), scanDouble(), checkRes() для проверки корректного ввода с консоли целочисленного значения, значения с плавающей точкой и проверкой падежа для слова "рубль" в итоговом выводе.