Skip to content

Гонка "24 часа Ле-Мана" - #1

Open
sergeevNikita42 wants to merge 2 commits into
mainfrom
dev
Open

sergeevNikita42 wants to merge 2 commits into
mainfrom
dev

Conversation

@sergeevNikita42

Copy link
Copy Markdown
Owner

Добрый день!
Созданы классы:

class Car предназначен для создания объектов (машин).
class Race Race отвечает за определение самой быстрой машины.
class Main:
• Запрашивает и проверяет корректность ввода;
• Создает объекты Car и передает их в объект Race для определения самой быстрой машины;
• Выводит результат: название самой быстрой машины.

Comment thread src/main/java/Car.java
Comment on lines +2 to +3
String name;
int speed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java
System.out.println("Введите скорость машины №" + carNumber + ":");
try {
speed = Integer.parseInt(scanner.nextLine());
if (speed > 0 && speed <= 250) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Race.java
Comment on lines +2 to +3
String fastestCarName;
int fastestSpeed;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants