Skip to content

Conversation

@SirGeorga
Copy link
Owner

…р счёта"

Pull Request между двумя ветками проекта.

String input = scanner.next();

// защита от присваивания некорректных значений
while (!isValidInt(input)) {

Choose a reason for hiding this comment

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

У Scanner есть удобный метод hasNextInt, можно сразу узнать без дополнительных проверок возможно ли интерпретировать строку как int


Bill bill = new Bill();
String completion = "";
while (completion.compareToIgnoreCase("Завершить") != 0) {

Choose a reason for hiding this comment

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

Можно просто equalsIgnoreCase

bill.addToList(scanner.next());
System.out.print("Введите стоимость товара: ");
input = scanner.next();
while (!isValidDouble(input)) {

Choose a reason for hiding this comment

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

По аналогии с int у Scanner есть метод hasNextDouble
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html#hasNextDouble%28%29

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.

3 participants