Skip to content

my 1st request - #72

Closed
kamberbattch wants to merge 3 commits into
Yandex-Practicum:masterfrom
kamberbattch:master
Closed

kamberbattch wants to merge 3 commits into
Yandex-Practicum:masterfrom
kamberbattch:master

Conversation

@kamberbattch

Copy link
Copy Markdown

hi

Comment thread src/main/java/Main.java Outdated
// ваш код начнется здесь
// вы не должны ограничиваться только классом Main и можете создавать свои классы по необходимости
System.out.println("Привет Мир");
Calculator calc = new Calculator();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно сделать методы и поля класса Calculator static, чтобы не приходилось создавать экземпляр класса. Тогда можно будет просто вызывать методы: Calculator.inputPersons(); и т.д.

Comment thread src/main/java/Main.java
String answer = scan.next();
if (answer.equalsIgnoreCase("n")) {
continue;
} else {break;}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В данном случае continue не нужно, потому что это последняя строчка кода в цикле и он и так начнет цикл с самого начала, даже если continue не будет

Comment thread src/main/java/Main.java
int ruble = (int) Math.floor(totalPrice);
int payPeople = (int) Math.floor(totalPrice/persons);
System.out.println("Вы заказали следующие продукты:\n" + names + "на сумму: " + totalPrice + " " + Calculator.payPeoples(ruble));
System.out.println("Каждый из " + persons + " человек заплатит по " + String.format("%.2f", totalPrice/persons) + " " + Calculator.payPeoples(payPeople));

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
} else {
System.out.println("Amount of persons must be integer > 1. Try again.");
scan.nextLine();
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

continue не нужен, потому что это и так последняя строчка кода в цикле

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