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

Пишем консольное приложение No1#1

Open
mfoxtrot wants to merge 7 commits intomain from
dev
Open

Пишем консольное приложение No1 #1
mfoxtrot wants to merge 7 commits intomain from
dev

Conversation

@mfoxtrot
Copy link
Owner

@mfoxtrot mfoxtrot commented Feb 8, 2023

No description provided.

Comment on lines 53 to 70
private String rubbleProperCase(Double sum) {
int intSum = (int)Math.floor(sum);

if (intSum%10==1) {
return "рубль";
}
else if (intSum%10==2 && intSum!=12) {
return "рубля";
}
else if (intSum%10==3 && intSum!=13) {
return "рубля";
}
else if (intSum%10==4 && intSum!=14) {
return "рубля";
}
else {
return "рублей";
}
Copy link

@ilshat-abdulin ilshat-abdulin Feb 9, 2023

Choose a reason for hiding this comment

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

⚠ Некорректно рассчитывается окончание. Например, если цена на каждого будет 114, то получается 114,00 рубля. Лучше переработать и учесть проверку остатка при делении на 100

Comment on lines 82 to 87
System.out.print("На сколько гостей разбить чек? ");
int numberOfPersons = scanner.nextInt();
if (numberOfPersons>1) {
bill = new Bill(numberOfPersons);
break;
}
Copy link

@ilshat-abdulin ilshat-abdulin Feb 9, 2023

Choose a reason for hiding this comment

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

⚠ Пользователь может ввести на вопрос про количество человек вместо чисел строки, и приложение упадет. Лучше такого не допускать, а обрабатывать. Можно использовать методы scanner.hasNextInt()/hasNextFloat() или try-catch

Comment on lines 98 to 102
System.out.print("Введите цену блюда: ");
double inputPrice = scanner.nextDouble();
Dish dish = new Dish(inputString, inputPrice);
bill.addDish(dish);

Copy link

@ilshat-abdulin ilshat-abdulin Feb 9, 2023

Choose a reason for hiding this comment

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

⚠ Пользователь может ввести на вопрос про стоимость товара вместо чисел строки, и приложение упадет. Лучше такого не допускать, а обрабатывать. Можно использовать методы scanner.hasNextInt()/hasNextFloat() или try-catch

}
System.out.println("Неверное значение. Количество гостей должно быть больше 1. Попробуйте еще раз.");
}
scanner.nextLine();//Вынужденная мера для обхода ошибки https://stackoverflow.com/questions/23450524/java-scanner-doesnt-wait-for-user-input
Copy link

@ilshat-abdulin ilshat-abdulin Feb 9, 2023

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

@ilshat-abdulin ilshat-abdulin ilshat-abdulin 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 によって変換されたページ (->オリジナル) /