Skip to content

Alpha version 1.0 - #1

Open
Amicratus wants to merge 3 commits into
mainfrom
dev
Open

Amicratus wants to merge 3 commits into
mainfrom
dev

Conversation

@Amicratus

Copy link
Copy Markdown
Owner

Добавил класс Calculator, в котором хранятся общая цена, количество людей, список товаров и список их цен:
double totalCost, int numberOfPeople, ArrayList listOfProducts, ArrayList costOfProducts.

Записан метод show(), который выводит все товары и итоговую сумму, которую должен оплатить каждый из людей.
Методы addProduct() и addProductCost() записывают название продукта и его цену соответственно.

Добавлен так же класс Formater с методами scanInt(), scanDouble(), checkRes() для проверки корректного ввода с консоли целочисленного значения, значения с плавающей точкой и проверкой падежа для слова "рубль" в итоговом выводе.

Comment thread src/main/java/Main.java Outdated
if(str.equalsIgnoreCase("Да")) {
calculator.addProduct();
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По хорошему надо выносить всю логику из класса Main. Этот класс обычно призван только стартануть программу, а все остальное должно быть сделано в специальных классах, как сейчас сделано с другими классами

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил

Comment thread src/main/java/Formater.java Outdated

public class Formater {

Scanner scanner = new Scanner(System.in);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил

Comment thread src/main/java/Calculator.java Outdated
private int numberOfPeople;
private double totalCost = 0;
private ArrayList<String> listOfProducts;
private ArrayList<Double> costOfProducts;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numberOfPeople, listOfProducts и costOfProducts - final

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил

@Amicratus

Copy link
Copy Markdown
Owner Author

Вынес из main все действия. Оставил только создание класса Calcualtor и его метод void start(), который запускает программу.

Так же доработал метод checkRes(double) в классе Formater. До этого программа неправильно выводило слово для чисел оканчивающихся на 11-14.

@Amicratus
Amicratus requested a review from faritowich January 9, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants