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

Проектная работа "24 часа Ле-Мана"#1

Open
AnastasiyaVL wants to merge 1 commit intomain from
dev
Open

Проектная работа "24 часа Ле-Мана" #1
AnastasiyaVL wants to merge 1 commit intomain from
dev

Conversation

@AnastasiyaVL
Copy link
Owner

@AnastasiyaVL AnastasiyaVL commented Nov 21, 2025

No description provided.

Copy link

@ArturNurtdinov ArturNurtdinov left a comment

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
public String name;
public int speed;
Copy link

@ArturNurtdinov ArturNurtdinov Nov 21, 2025

Choose a reason for hiding this comment

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

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

public static void main(String[] args) {
System.out.println("Hello world!");
Scanner scanner = new Scanner(System.in);
Auto[] auto = new Auto[3];
Copy link

@ArturNurtdinov ArturNurtdinov Nov 21, 2025

Choose a reason for hiding this comment

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

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

Comment on lines +13 to +21
while (true) {
System.out.print("Введите название машины No" + (i + 1) + ": ");
name = scanner.nextLine().trim();
if (!name.isEmpty()) {
break;
} else {
System.out.println("Ошибка: название не может быть пустым. Попробуйте снова.");
}
}
Copy link

@ArturNurtdinov ArturNurtdinov Nov 21, 2025

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