Skip to content

Задание к спринту №2 - #1

Open
MetelikovSergey wants to merge 3 commits into
mainfrom
dev
Open

MetelikovSergey wants to merge 3 commits into
mainfrom
dev

Conversation

@MetelikovSergey

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Main.java Outdated

while (true){
System.out.println("Введите количество гостей");
numberOfGuests = 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.

⚠️ Если передать в этот момент произвольную строку программа завершит работу с исключением. Перед тем, как прочитать int из сканнера, нужно сначала проверить возможно ли это при помощи соответствующего метода hasNextInt

Comment thread src/main/java/Calculator.java Outdated

public class Calculator {
public static void calculete(int countGuest) {
Scanner scanner = 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/Calculator.java Outdated
} else {
product.nameProduct += name + "\n ";
System.out.println("Введите стоимость товара (цифрой)");
product.priceProduct += scanner.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.

Тоже самое как с hasNextInt только hasNextDouble

corrections
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