Skip to content

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

Open
Aslan4242 wants to merge 4 commits into
mainfrom
dev
Open

Aslan4242 wants to merge 4 commits into
mainfrom
dev

Conversation

@Aslan4242

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Utils.java
*/
public static int getPersonCount() {
while (true) {
String personCount = Main.scanner.next().replace(',', '.');

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 есть удобный метод hasNextInt, можно сразу узнать без дополнительных проверок возможно ли интерпретировать строку как int

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Такая реализация для того чтобы можно было вводить и '1' и '1.0' и '1,0' в качестве корректного ответа

Comment thread src/main/java/Dish.java
while (true) {
String price = Main.scanner.next().replace(',', '.');

if (!Utils.isNumber(price)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Тут тоже нужно для того чтобы можно было вводить и '1.0' и '1,0' в качестве корректного ответа

Comment thread src/main/java/Utils.java Outdated
public static String formatPriceData(double price) {
String formattedPrice = String.format(Locale.US, "%.2f ", price);
String rubleWord;
int lastDigitInPrice = (int) (Math.abs(price) % 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.

Можно на самом деле без вызова Math.abs, по заданию хотят округление до целых, приведение double к int как раз это и делает, и лучше сначала привести, потом взять остаток от деления

Copy link
Copy Markdown
Owner Author

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