Skip to content

Проектная работа №1. Задача по рассчету лидера гонки 24 часа - #1

Open
Augmentin wants to merge 4 commits into
mainfrom
dev
Open

Augmentin wants to merge 4 commits into
mainfrom
dev

Conversation

@Augmentin

Copy link
Copy Markdown
Owner

Проектная работа №1
try 1

Comment thread src/main/java/Car.java Outdated
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 Outdated
Comment on lines +23 to +26
if (!Arrays.asList(new String[]{ "да", "lf", "y", "yes"}).contains(continueAnswer.trim().toLowerCase())) {
System.out.println("До свидания");
break;
}

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/Main.java Outdated
System.out.println("Введите скорость машины №" + carNumber);
if (scanner.hasNextInt()) {
int speed = scanner.nextInt();
if (0 < speed && 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 Outdated
Comment on lines +5 to +6
Car currentLeader;
int durationHours = 24;

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 Outdated
Car currentLeader;
int durationHours = 24;

public Car getLeader(Car car) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

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