Skip to content

Ольга Блохина. Практическая работа#2

Closed
olya-woo wants to merge 2 commits intoYandex-Practicum:mainfrom
olya-woo:main
Closed

Ольга Блохина. Практическая работа#2
olya-woo wants to merge 2 commits intoYandex-Practicum:mainfrom
olya-woo:main

Conversation

@olya-woo
Copy link
Copy Markdown

No description provided.

} else if (b == 2 | b == 3 | b == 4) {
amountOfRubles = String.format("%.2f", floatAmount) + " рубля";
} else {
amountOfRubles = String.format("%.2f", floatAmount) + " рублей";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Код amountOfRubles = String.format("%.2f", floatAmount) повторяется в каждой ветке, лучше его вынести после if-else

amountOfRubles = String.format("%.2f", floatAmount) + " рублей";
} else if (b == 1) {
amountOfRubles = String.format("%.2f", floatAmount) + " рубль";
} else if (b == 2 | b == 3 | b == 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.

Можно писать b >= 2 && b <= 4

public void writeRuble(double floatAmount) {
int amount = (int) Math.floor(floatAmount);
int a = amount % 100;
int b = a % 10;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Лучше дать названия более понятные, чтобы другим программистам с первого взгляда было ясно, что они значат

product.name = scanner.next();
listProduct = listProduct + product.name + "\n";
boolean isRightPrice = false;
while (!isRightPrice) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно обойтись без переменной, тут писать while (true), а в месте, где нужен выход из цикла - писать break

@s-buvaka s-buvaka closed this Dec 23, 2022
sn00pg0d referenced this pull request in sn00pg0d/Java-Module-Project-YP Dec 28, 2022
Домашнее задание Спринт №2 29/12/22
myCherryPie added a commit to myCherryPie/Java-Module-Project-YP-PracticalWork1 that referenced this pull request Jan 8, 2024
практическая работа 1, правки от 1ого ревью
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.

3 participants