Skip to content

Выполненное задание - #1

Open
develop-mdv wants to merge 1 commit into
mainfrom
dev
Open

develop-mdv wants to merge 1 commit into
mainfrom
dev

Conversation

@develop-mdv

Copy link
Copy Markdown
Owner

Выполненное задание проектная работа №1

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(String.format("Введите скорость автомобиля №%d", i + 1));
if (scanner.hasNextInt()){
speed = scanner.nextInt();
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
@@ -0,0 +1,11 @@
public class Race {
Car leader = new Car("", 0);
int leader_distance;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Переменные в Java принято именовать в соответствии с camelCase, лучше переименовать данную переменную

Comment thread src/main/java/Race.java
Comment on lines +2 to +3
Car leader = new Car("", 0);
int leader_distance;

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