Skip to content

Conversation

@Mig239116
Copy link
Owner

No description provided.

return speed;
}

public void setName(String name) {

Choose a reason for hiding this comment

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

Сеттеры по идее здесь лишние, так как поля передаются при создании объекта в конструкторе

Copy link
Owner Author

Choose a reason for hiding this comment

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

Исправил

name = scanner.next();
while (true) {
System.out.println("— Введите скорость машины №" + i +":");
speed = scanner.nextInt();

Choose a reason for hiding this comment

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

Здесь при вводе нецелочисленных значений будет креш, который нигде не обрабатывается. Необходимо добавить обработку и попросить пользователя ввести данные заново

Copy link
Owner Author

Choose a reason for hiding this comment

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

Исправил

private Car leader;
private Integer time = 24;

private Map<Car, Integer> participantsResults;

Choose a reason for hiding this comment

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

Можно обойтись без хранения всех машин в мапе, если сразу при вводе данных определять победителя, таким образом программа будет работать быстрее и требовать меньше памяти

Copy link
Owner Author

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