Skip to content

Практическая работа №1 - #1

Open
Dyshman42 wants to merge 1 commit into
mainfrom
dev
Open

Dyshman42 wants to merge 1 commit into
mainfrom
dev

Conversation

@Dyshman42

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Auto.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
Comment on lines +14 to +17
String input = scanner.nextLine().trim();
if(input.isEmpty()){
continue;
}

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
}
try {
int speed = Integer.parseInt(input);
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 +4
String winner = "";
int spaceValue = 0;

Copy link
Copy Markdown

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.

2 participants