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

add logic of Main, Car and Race classes#1

Open
MaxDDM wants to merge 1 commit intomain from
dev
Open

add logic of Main, Car and Race classes #1
MaxDDM wants to merge 1 commit intomain from
dev

Conversation

@MaxDDM
Copy link
Owner

@MaxDDM MaxDDM commented Feb 11, 2026

Сделана первая работа в соответствии с требованиями.

Comment on lines +2 to +3
String name;
short speed;
Copy link

@ArturNurtdinov ArturNurtdinov Feb 11, 2026

Choose a reason for hiding this comment

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

Поля лучше пометить final, тем самым исключив возможность их модификации извне

continue;
}

if (speed <= 0 || speed > 250) {
Copy link

@ArturNurtdinov ArturNurtdinov Feb 11, 2026

Choose a reason for hiding this comment

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

Минимальную и максимальную скорости лучше вынести в константы для повышения читабельности кода

}

break;
} while (true);
Copy link

@ArturNurtdinov ArturNurtdinov Feb 11, 2026

Choose a reason for hiding this comment

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

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

Comment on lines +55 to +57
Car car1 = createCar(1);
Car car2 = createCar(2);
Car car3 = createCar(3);
Copy link

@ArturNurtdinov ArturNurtdinov Feb 11, 2026

Choose a reason for hiding this comment

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

Этот код с созданием трёх машин лучше вынести в цикл, чтобы не копировать блоки кода друг за другом

@@ -0,0 +1,23 @@
public class Race {
Car car1, car2, car3;
Copy link

@ArturNurtdinov ArturNurtdinov Feb 11, 2026

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

Reviewers

1 more reviewer

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