Skip to content

Проектная работа 1 - #85

Open
Usynin1994 wants to merge 1 commit into
Yandex-Practicum:masterfrom
Usynin1994:master
Open

Usynin1994 wants to merge 1 commit into
Yandex-Practicum:masterfrom
Usynin1994:master

Conversation

@Usynin1994

Copy link
Copy Markdown

No description provided.

@Usynin1994
Usynin1994 changed the base branch from main to master October 24, 2022 16:33
@Usynin1994
Usynin1994 changed the base branch from master to main October 24, 2022 16:50
@Usynin1994 Usynin1994 closed this Oct 24, 2022
@Usynin1994 Usynin1994 reopened this Oct 24, 2022
@Usynin1994
Usynin1994 changed the base branch from main to master October 24, 2022 16:59
} else {
food = food + name + "\n";
System.out.println("Введите цену в формате \"Рубли,Копейки\"");
float coast = scanner.nextFloat();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Пользователь может ввести на вопрос про стоимость товара вместо числа строку, и приложение упадет. Для количества человек ты обрабатываешь такую ситуацию через hasNextInt, стоит добавить обработку и для стоимости, чтобы приложение не падало

private String getRightWord (float n) {
n = (int) Math.floor(n);
n = Math.abs(n) % 100;
int n1 = (int) (n % 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.

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

if (n > 10 && n < 20) return "рублей";
if (n1 > 1 && n1 < 5) return "рубля";
if (n1 == 1) return "рубль";
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