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

пул реквест для первого проекта в яндекс практикуме#1

Open
posleflamingo wants to merge 1 commit intomain from
dev
Open

пул реквест для первого проекта в яндекс практикуме #1
posleflamingo wants to merge 1 commit intomain from
dev

Conversation

@posleflamingo
Copy link
Owner

@posleflamingo posleflamingo commented May 17, 2025

No description provided.

Komm mit Im Gleichschritt
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 +15
class Car {
private String name;
private int speed;
public Car(String name, int speed) {
this.name = name;
this.speed = speed;
}
public String getName() {
return name;
}
public int getSpeed() {
return speed;
}
}
Copy link

@ArturNurtdinov ArturNurtdinov May 17, 2025

Choose a reason for hiding this comment

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

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

private int maxDistance = 0;

public void checkLeader(Car car) {
int distance = car.getSpeed() * 24;
Copy link

@ArturNurtdinov ArturNurtdinov May 17, 2025

Choose a reason for hiding this comment

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

Для повышения читабельности кода число 24 лучше вынести в константу с говорящим названием

System.out.println("Введите скорость машины No" + i + ":");
if (scanner.hasNextInt()) {
speed = scanner.nextInt();
if (speed > 0 && speed <= 250) {
Copy link

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