Skip to content

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

Open
Aeeiii wants to merge 1 commit into
mainfrom
dev
Open

Aeeiii wants to merge 1 commit into
mainfrom
dev

Conversation

@Aeeiii

@Aeeiii Aeeiii commented Feb 11, 2024

Copy link
Copy Markdown
Owner

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

Comment thread src/main/java/Main.java
}

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java
}
}

class Product {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java
}

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

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

Copy link
Copy Markdown

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)

Comment thread src/main/java/Main.java
} else if (i == 2 || i == 3 || i == 4) {
return "рубля";
} else {
return "рублей";

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