Skip to content

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

Open
mfoxtrot wants to merge 7 commits into
mainfrom
dev
Open

mfoxtrot wants to merge 7 commits into
mainfrom
dev

Conversation

@mfoxtrot

@mfoxtrot mfoxtrot commented Feb 8, 2023

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Main.java
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
Copy Markdown

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 thread src/main/java/Main.java
Comment on lines +82 to +87
System.out.print("На сколько гостей разбить чек? ");
int numberOfPersons = scanner.nextInt();
if (numberOfPersons>1) {
bill = new Bill(numberOfPersons);
break;
}

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()/hasNextFloat() или try-catch

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

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()/hasNextFloat() или try-catch

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

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