Skip to content

Conversation

@Dyshman42
Copy link
Owner

No description provided.

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

Choose a reason for hiding this comment

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

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

Comment on lines +14 to +17
String input = scanner.nextLine().trim();
if(input.isEmpty()){
continue;
}

Choose a reason for hiding this comment

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

Код для считывания непустой строки с ввода лучше вынести в отдельную функцию - код, разделённый на небольшие функции, легче читать, поддерживать и переиспользовать

}
try {
int speed = Integer.parseInt(input);
if (speed > 0 && speed <= 250) {

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 +4
String winner = "";
int spaceValue = 0;

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