Skip to content

Первая версия проектной работы №1 - Консольное приложение "Калькулято… - #1

Open
SirGeorga wants to merge 1 commit into
devfrom
main
Open

SirGeorga wants to merge 1 commit into
devfrom
main

Conversation

@SirGeorga

Copy link
Copy Markdown
Owner

…р счёта"

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

Comment thread src/main/java/Main.java
String input = scanner.next();

// защита от присваивания некорректных значений
while (!isValidInt(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.

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

Comment thread src/main/java/Main.java

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java
bill.addToList(scanner.next());
System.out.print("Введите стоимость товара: ");
input = scanner.next();
while (!isValidDouble(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.

По аналогии с 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.

2 participants