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

my 1st request#72

Closed
kamberbattch wants to merge 3 commits intoYandex-Practicum:master from
kamberbattch:master
Closed

my 1st request #72
kamberbattch wants to merge 3 commits intoYandex-Practicum:master from
kamberbattch:master

Conversation

@kamberbattch
Copy link

@kamberbattch kamberbattch commented Oct 12, 2022

hi

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

@faritowich faritowich Oct 12, 2022

Choose a reason for hiding this comment

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

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

String answer = scan.next();
if (answer.equalsIgnoreCase("n")) {
continue;
} else {break;}
Copy link

@faritowich faritowich Oct 13, 2022

Choose a reason for hiding this comment

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

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

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

@faritowich faritowich Oct 13, 2022

Choose a reason for hiding this comment

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

Лучше объединить два идущих подряд println в один

} else {
System.out.println("Amount of persons must be integer > 1. Try again.");
scan.nextLine();
continue;
Copy link

@faritowich faritowich Oct 13, 2022

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

Reviewers

1 more reviewer

@faritowich faritowich faritowich left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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