Skip to content

Проектная работа № 1 - #3

Merged
BOGDAN1986 merged 3 commits into
mainfrom
dev
Mar 1, 2023
Merged

BOGDAN1986 merged 3 commits into
mainfrom
dev

Conversation

@BOGDAN1986

Copy link
Copy Markdown
Owner

Project # 1
Merge pull request №3

@BOGDAN1986
BOGDAN1986 merged commit 737f51f into main Mar 1, 2023
Comment thread src/main/java/Main.java
}
}
}
class GroceryList {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Лучше вынести в отдельный файл

Comment thread src/main/java/Main.java

while (true) {
String name;
Scanner nameProduct = new Scanner(System.in);

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, а не создавать каждый раз новый.

Comment thread src/main/java/Main.java
System.out.println("На сколько персон разделить счет?"); //Количество людей

while (true) {
int people = scanner.nextInt();

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

double price;
System.out.println("Введите стоимость блюда"); // Ввести стоимость
price = nameProduct.nextDouble();

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