Skip to content

Pull request from dev to main#3

Open
FiLbI4 wants to merge 9 commits intomainfrom
dev
Open

Pull request from dev to main#3
FiLbI4 wants to merge 9 commits intomainfrom
dev

Conversation

@FiLbI4
Copy link
Owner

@FiLbI4 FiLbI4 commented Feb 12, 2026

Pull Request

for (int i = 1; i <= 3; i++) {
//Работа с наименованием
String carName = "";
while (true) {

Choose a reason for hiding this comment

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

Не рекомендую писать бесконечные циклы через while (true) - лучше всегда явно прописывать условие выхода из цикла, чтобы уменьшить вероятность ошибиться и повысить читабельность кода

while (true) {
System.out.println(" - Введите название машины № " + i);
carName = scanner.nextLine();
if (carName.isBlank()) {

Choose a reason for hiding this comment

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

Код для считывания непустой строки с ввода лучше вынести в отдельную функцию - код, разделённый на небольшие функции, легче читать, поддерживать и переиспользовать

int speed;
while (true) {
System.out.println(" - Введите скорость машины № " + i);
String input = scanner.nextLine();

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