Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Pull request for extraction with my project work#2

Open
DexMP wants to merge 9 commits intomain from
dev
Open

Pull request for extraction with my project work #2
DexMP wants to merge 9 commits intomain from
dev

Conversation

@DexMP
Copy link
Owner

@DexMP DexMP commented Oct 24, 2023

Hi, this is my first PR project

Comment on lines +17 to +20
Scanner scanner_humans = new Scanner(System.in);
Scanner scanner_products = new Scanner(System.in);
Scanner scanner_prices = new Scanner(System.in);

Copy link

@kgornostaeva kgornostaeva Oct 25, 2023

Choose a reason for hiding this comment

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

🍏 Для всего взаимодействия с пользователем достаточно открыть один сканнер

float summ = 0;

// Сканеры
Scanner scanner_humans = new Scanner(System.in);
Copy link

@kgornostaeva kgornostaeva Oct 25, 2023

Choose a reason for hiding this comment

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

🍏 В Java принято переменные писать в camelCase, а названия классов CamelCase.
SNAKE_CASE используется для именования констант, а snake_case - для именования xml файлов.
https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html


// Получаем количество людей
while (true) {
if (scanner_humans.hasNextInt()) {
Copy link

@kgornostaeva kgornostaeva Oct 25, 2023

Choose a reason for hiding this comment

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

👏 Круто, что делаешь проверку на наличие числа

DexMP reacted with heart emoji
float forPerson = summ / humans;
int rubles = (int) forPerson;

System.out.println("Сумма на каждого человека " + String.format("%.2f", forPerson) + " " + grammar(rubles));
Copy link

@kgornostaeva kgornostaeva Oct 25, 2023

Choose a reason for hiding this comment

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

🍏 При печати в памяти будут создаваться промежуточные строки из-за множественного использования оператора "+". Можно использовать StringBuilder, который сформирует только результирующую строку, или String.format()

Copy link

🍏 Классно было бы подсказать пользователю, как выйти из сценария

DexMP reacted with thumbs up emoji

DexMP and others added 2 commits October 27, 2023 20:14
Изменение ревьюера
Co-authored-by: kgornostaeva <48408134+kgornostaeva@users.noreply.github.com>
Изменения ревьюера
Co-authored-by: kgornostaeva <48408134+kgornostaeva@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@kgornostaeva kgornostaeva kgornostaeva left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /