-
Notifications
You must be signed in to change notification settings - Fork 222
Проектная работа 1 #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Проектная работа 1 #104
Conversation
src/main/java/Main.java
Outdated
| switch (lastNum) { | ||
| case 1: | ||
| rubles = "рубль"; | ||
| case 2 | 3 | 4: | ||
| rubles = "рубля"; | ||
| default: | ||
| rubles = "рублей"; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в случае если totalPrice будет = 11, выведется не верное окончание
src/main/java/Main.java
Outdated
| while (true) { | ||
| System.out.println("Введите название товара или введите команду \"Завершить\"."); | ||
| String productName = scanner.next(); | ||
| if (productName.equalsIgnoreCase("finish")) { | ||
| System.out.println("Добавленные товары: " + "\n" + allProducts); | ||
| break; | ||
| } else { | ||
| allProducts = allProducts + productName + "\n"; | ||
| while (true) { | ||
| System.out.println("Введите стоимость товара в формате \"рубли,копейки\"."); | ||
| productPrice = scanner.nextDouble(); | ||
| if (productPrice <= 0) { | ||
| System.out.println("Некорректное значение."); | ||
| } else { | ||
| break; | ||
| } | ||
| } | ||
| totalPrice = totalPrice + productPrice; | ||
| System.out.println("Товар добавлен в чек."); | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В случае если ввести не число, то приложение упадет, этого можно избежать с помощью конструкции try catch
|
Добавлен отлов ошибок и проверка на цифры |
Жаль, не было времени полностью вникнуть в задачу, зато сделала сама и без помощи. Строго не судите, пожалуйста, я правда старалась. Очень жду критику и предложения, как улучшить код. Спасибо!