Skip to content

Pull request for extraction with my project work#2

Open
DexMP wants to merge 9 commits intomainfrom
dev
Open

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

Conversation

@DexMP
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown

Choose a reason for hiding this comment

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

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

float forPerson = summ / humans;
int rubles = (int) forPerson;

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

Choose a reason for hiding this comment

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

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

@kgornostaeva
Copy link
Copy Markdown

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

DexMP and others added 2 commits October 27, 2023 20:14
Изменение ревьюера

Co-authored-by: kgornostaeva <[email protected]>
Изменения ревьюера

Co-authored-by: kgornostaeva <[email protected]>
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