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

Open
develop-mdv wants to merge 1 commit intomain from
dev
Open

Выполненное задание #1
develop-mdv wants to merge 1 commit intomain from
dev

Conversation

@develop-mdv
Copy link
Owner

@develop-mdv develop-mdv commented Mar 20, 2025

Выполненное задание проектная работа No1

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

@ArturNurtdinov ArturNurtdinov Mar 20, 2025

Choose a reason for hiding this comment

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

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

System.out.println(String.format("Введите скорость автомобиля No%d", i + 1));
if (scanner.hasNextInt()){
speed = scanner.nextInt();
if (speed>0 && speed<=250) {
Copy link

@ArturNurtdinov ArturNurtdinov Mar 20, 2025

Choose a reason for hiding this comment

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

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

@@ -0,0 +1,11 @@
public class Race {
Car leader = new Car("", 0);
int leader_distance;
Copy link

@ArturNurtdinov ArturNurtdinov Mar 20, 2025

Choose a reason for hiding this comment

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

Переменные в Java принято именовать в соответствии с camelCase, лучше переименовать данную переменную

Comment on lines +2 to +3
Car leader = new Car("", 0);
int leader_distance;
Copy link

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