Skip to content

Conversation

@Fandorina
Copy link

Жаль, не было времени полностью вникнуть в задачу, зато сделала сама и без помощи. Строго не судите, пожалуйста, я правда старалась. Очень жду критику и предложения, как улучшить код. Спасибо!

Comment on lines 68 to 75
switch (lastNum) {
case 1:
rubles = "рубль";
case 2 | 3 | 4:
rubles = "рубля";
default:
rubles = "рублей";
}

Choose a reason for hiding this comment

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

в случае если totalPrice будет = 11, выведется не верное окончание

Comment on lines 41 to 62
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("Товар добавлен в чек.");
}

}

Choose a reason for hiding this comment

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

В случае если ввести не число, то приложение упадет, этого можно избежать с помощью конструкции try catch

@Fandorina
Copy link
Author

Добавлен отлов ошибок и проверка на цифры

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