Skip to content

«Калькулятор счёта» - #1

Open
PetrovaOla wants to merge 2 commits into
mainfrom
dev
Open

PetrovaOla wants to merge 2 commits into
mainfrom
dev

Conversation

@PetrovaOla

Copy link
Copy Markdown
Collaborator

Консольное приложение №1
«Калькулятор счёта»

Comment thread src/main/java/Main.java
System.out.println("Список продуктов: ");
productList.forEach((s) -> System.out.println(s.name + " : " + s.price));
System.out.println("Итоговая сумма: " + parseRubCase(sum));
System.out.println("Итоговая сумма на каждого человека: " + parseRubCase(sum / count));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Такие подряд идущие println лучше объединять в один.

Comment thread src/main/java/Main.java
while (count < 2);
}

private static void addProductList(int count) {

Copy link
Copy Markdown

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/Main.java
}
}

while (count < 2);

Copy link
Copy Markdown

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/Main.java
do {
System.out.println("Введите цену товара в формате рубли.копейки");
String str = scanner.next();
if (str.trim().toUpperCase().toLowerCase().contains("завершить")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

есть метод equalsIgnoreCase

Comment thread src/main/java/Main.java
active = false;
break;
}
if (!str.matches("[0-9]+\\.[0-9]+")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Круто, что использованы регулярки!

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