Skip to content

Conversation

@Seetochka
Copy link
Owner

Создание консольного приложения "24 часа Ле-Мана"

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;

Choose a reason for hiding this comment

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

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

public class Race {
private final static int RACE_TIME = 24;

public String leader;

Choose a reason for hiding this comment

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

Данную переменную лучше сделать приватной, чтобы снаружи класса нельзя было её поменять, тем самым сломав логику работы этого класса (т.к. переменная должна менять своё значение только в функции checkLeader). Для получения имени победителя лучше написать отдельную функцию-геттер

System.out.println("— Введите скорость машины №" + i + ": ");
carSpeedStr = scanner.nextLine().trim();

if (!carSpeedStr.matches("-?\\d+")) {

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants