Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Alpha version 1.0#1

Open
Amicratus wants to merge 3 commits intomain from
dev
Open

Alpha version 1.0 #1
Amicratus wants to merge 3 commits intomain from
dev

Conversation

@Amicratus
Copy link
Owner

@Amicratus Amicratus commented Jan 7, 2024

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

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

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

if(str.equalsIgnoreCase("Да")) {
calculator.addProduct();
}
}
Copy link

@faritowich faritowich Jan 8, 2024

Choose a reason for hiding this comment

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

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

Copy link
Owner Author

@Amicratus Amicratus Jan 9, 2024

Choose a reason for hiding this comment

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

Исправил


public class Formater {

Scanner scanner = new Scanner(System.in);
Copy link

@faritowich faritowich Jan 8, 2024

Choose a reason for hiding this comment

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

private

Copy link
Owner Author

@Amicratus Amicratus Jan 9, 2024

Choose a reason for hiding this comment

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

Исправил

private int numberOfPeople;
private double totalCost = 0;
private ArrayList<String> listOfProducts;
private ArrayList<Double> costOfProducts;
Copy link

@faritowich faritowich Jan 8, 2024

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
Owner Author

@Amicratus Amicratus Jan 9, 2024

Choose a reason for hiding this comment

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

Исправил

Copy link
Owner Author

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@faritowich faritowich Awaiting requested review from faritowich

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /