Skip to content

Сдача задания - #63

Open
Artem-Grigorash wants to merge 15 commits into
Yandex-Practicum:masterfrom
Artem-Grigorash:master
Open

Artem-Grigorash wants to merge 15 commits into
Yandex-Practicum:masterfrom
Artem-Grigorash:master

Conversation

@Artem-Grigorash

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/Main.java Outdated
int persons = in.nextInt();
while (persons<=1){
out.println("Non-correct value for counting, the number of people must be more than one");
out.println("Please enter the correct value");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно объединить два println в один. Перенос строки можно сделать, вставив в строку "\n"

Comment thread src/main/java/Main.java
out.println("Please enter the correct value");
persons = in.nextInt();
}
Positions[] pos = new Positions[100];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Лучше будет использовать не массив, а ArrayList. В большинстве случаев у нас действительно будет не более 100 товаров, но наверняка мы знать не можем.

Comment thread src/main/java/Main.java Outdated
out.println("Great! See you later");
}
else
out.println("Please, enter Yes/No");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

В комментарии к заданию я не написал ещё один важный момент, который стоит поправить - сейчас практически весь код написан в методе main класса Main. Это сильно перегружает код, так как разная логика (ввод людей, ввод продуктов, конечный вывод) написаны в одном методе.
Я рекомендую разбить программу на отдельные классы с отдельными методами. Например, можно создать отдельные классы/методы, отвечающие за обработку ввода количества людей, обработку ввода продуктов, конечный вывод, удаление продуктов.

Вообще способов организовать код бесконечность, это будет приходить с опытом. На эту тему могу посоветовать книгу Роберта Мартина "Чистый Код".

Comment thread src/main/java/Main.java Outdated
sum+=pos[j].price;
out.println("Total sum: " + String.format("%.2f", sum) + " rubles");
out.println(("Everyone has to pay: ") + String.format("%.2f", sum/persons)+ " rubles");
out.println("Do you want to correct the list?");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Также можно объединить эти println в один.

Comment thread src/main/java/Main.java
String nextPosition = in.next();
out.println("Enter the price of the dish in the format rub,kop");
double nextPrice = in.nextDouble();
int i = 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.

Лучше использовать такой нейминг, чтобы по названию было понятно, что переменная означает.

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