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#1

Open
steeppap wants to merge 1 commit intomain from
dev
Open

Практическая 1 #1
steeppap wants to merge 1 commit intomain from
dev

Conversation

@steeppap
Copy link
Owner

@steeppap steeppap commented Oct 1, 2025

No description provided.

Comment on lines +11 to +18
while (true) {
carName = scanner.nextLine().trim();
if (carName.isEmpty()) {
System.out.println("Название автомобиля не может быть пустым или состоять из пробелов, повторите ввод");
} else {
break;
}
}
Copy link

@ArturNurtdinov ArturNurtdinov Oct 1, 2025

Choose a reason for hiding this comment

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

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

while (true) {
if (scanner.hasNextInt()) {
carSpeed = scanner.nextInt();
if (carSpeed < 0 || carSpeed > 250) {
Copy link

@ArturNurtdinov ArturNurtdinov Oct 1, 2025

Choose a reason for hiding this comment

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

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

Comment on lines +46 to +55
}









Copy link

@ArturNurtdinov ArturNurtdinov Oct 1, 2025

Choose a reason for hiding this comment

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

Лишние пустые строчки лучше удалить, чтобы не засоряли код. Достаточно использовать 1 пустую строку для разделения логически делимых блоков в коде

@@ -0,0 +1,14 @@
public class Race {
String leader;
Copy link

@ArturNurtdinov ArturNurtdinov Oct 1, 2025

Choose a reason for hiding this comment

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

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

Comment on lines +2 to +3
String carName;
int carSpeed;
Copy link

@ArturNurtdinov ArturNurtdinov Oct 1, 2025

Choose a reason for hiding this comment

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

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

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