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

Реализованный калькулятор счета#1

Open
Aeeiii wants to merge 1 commit intomain from
dev
Open

Реализованный калькулятор счета #1
Aeeiii wants to merge 1 commit intomain from
dev

Conversation

@Aeeiii
Copy link
Owner

@Aeeiii Aeeiii commented Feb 11, 2024

Pull request для сдачи калькулятора разделения счета.

}

class SplitBill { // основной класс
Scanner scanner = new Scanner(System.in);
Copy link

@i-masloed i-masloed Feb 11, 2024

Choose a reason for hiding this comment

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

  • хорошей практикой является делать вызов scanner.close() после того, как сканнер больше не используется. Это необходимо для того, что бы этот объект не потреблял ресурсы, тогда когда это уже не требуется.

}
}

class Product {
Copy link

@i-masloed i-masloed Feb 11, 2024

Choose a reason for hiding this comment

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

Рекомендация: в java принято правило: один класс-один файл.

}

private String rublesEnd(double rubles) { // процедура возвращает слово рубль с правильным окончанием
if (((int) rubles % 100) > 10 && ((int) rubles % 100) < 21 ) {
Copy link

@i-masloed i-masloed Feb 11, 2024

Choose a reason for hiding this comment

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

rubles % 100 и rubles % 10 используется несколько раз , стоит вынести в переменную

int i = (int) rubles % 10; // выясняем последнюю цифру
if (i == 1) {
return "рубль";
} else if (i == 2 || i == 3 || i == 4) {
Copy link

@i-masloed i-masloed Feb 11, 2024

Choose a reason for hiding this comment

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

if (i >= 2 || i<=4)

} else if (i == 2 || i == 3 || i == 4) {
return "рубля";
} else {
return "рублей";
Copy link

@i-masloed i-masloed Feb 11, 2024

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

Reviewers

1 more reviewer

@i-masloed i-masloed i-masloed 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.

2 participants

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