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

КОНСОЛЬНОЕ ПРИЛОЖЕНИЕ 1#75

Open
AlekseyChist wants to merge 2 commits intoYandex-Practicum:master from
AlekseyChist:master
Open

КОНСОЛЬНОЕ ПРИЛОЖЕНИЕ 1 #75
AlekseyChist wants to merge 2 commits intoYandex-Practicum:master from
AlekseyChist:master

Conversation

@AlekseyChist
Copy link

@AlekseyChist AlekseyChist commented Oct 17, 2022

No description provided.

System.out.println("Некорректное значение для подсчёта.");
}
add.getNumberOfPpl(numberOfPeople);//добавляем кол-во людей
} while (numberOfPeople < 2);
Copy link

@faritowich faritowich Oct 17, 2022

Choose a reason for hiding this comment

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

Имеет смысл выделить такие логические части программы (обработка ввода количества людей, ввод товаров) в отдельные методы, чтобы было проще их воспринимать, и здесь их последовательно вызывать

add.count();
add.nameOfCurrency();
}
private static void typeGoods() {
Copy link

@faritowich faritowich Oct 17, 2022

Choose a reason for hiding this comment

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

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

@@ -0,0 +1,58 @@
public class Calculator {

private Product[] array = new Product[20];
Copy link

@faritowich faritowich Oct 17, 2022

Choose a reason for hiding this comment

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

Лучше использовать список из коллекций - например, ArrayList, потому что размер массива ограничен, а теоретически количество товаров неограниченное

Copy link
Author

@AlekseyChist AlekseyChist Oct 17, 2022

Choose a reason for hiding this comment

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

Мой эррей же расширяется

System.out.println("\nСумма для каждого составляет: " + sumForEach + " рубля.");
} else if (rounded == 0)
System.out.println("\nСумма для каждого составляет: " + sumForEach + " рублей.");
}
Copy link

@faritowich faritowich Oct 17, 2022

Choose a reason for hiding this comment

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

Есть принцип, который называется DRY - Don't repeat yourself. По этому правилу, если видишь, что есть многократно повторяющиеся участки кода, то их можно объединить. Здесь, например, изменяется лишь окончание, поэтому можно сделать строку, которая будет изменяться в зависимости от rounded, и затем присоединять её к предложению

AlekseyChist reacted with thumbs up emoji
Copy link
Author

Простите я сильно болел гриппом, вот поправился, внес правки.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@faritowich faritowich faritowich 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 によって変換されたページ (->オリジナル) /