Skip to content

Conversation

@ArturSafiullinn
Copy link
Owner

Домашнее задание от Артура Сафиуллина проект гонка Ле Ман.
Студент курса по Android-разработке. Когорта №27

Comment on lines +1 to +8
public class Car {
String carName;
int carSpeed;
Car (String carName, int carSpeed) {
this.carName = carName;
this.carSpeed = carSpeed;
}
}
Copy link

Choose a reason for hiding this comment

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

В Джаве принято делать поля приватными и писать для них геттеры и сеттеры.

Comment on lines +10 to +26
System.out.println("Введите скорость машины первого участника (это должно быть число больше 0 и меньше или равно 250):");
String inputCarSpeed = userInput.nextLine();
int carSpeed = inputCarSpeedToInt(inputCarSpeed);
Car firstCar = new Car(carName, carSpeed);
Race race = new Race();
race.whoIsWinner(firstCar);
System.out.println("Введите название машины второго участника:");
carName = userInput.nextLine();
System.out.println("Введите скорость машины второго участника (это должно быть число больше 0 и меньше или равно 250):");
inputCarSpeed = userInput.nextLine();
carSpeed = inputCarSpeedToInt(inputCarSpeed);
Car secondCar = new Car(carName, carSpeed);
race.whoIsWinner(secondCar);
System.out.println("Введите название машины третьего участника:");
carName = userInput.nextLine();
System.out.println("Введите скорость машины третьего участника (это должно быть число больше 0 и меньше или равно 250):");
inputCarSpeed = userInput.nextLine();
Copy link

Choose a reason for hiding this comment

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

Правильнее было бы сделать это в цикле

Comment on lines +45 to +50
} catch (NumberFormatException e) {
System.out.println("Неверно введена скорость! Введите число больше 0 и меньше или равной 250!");
Scanner userInputSpeed = new Scanner(System.in);
inputSpeed = userInputSpeed.nextLine();
}
}
Copy link

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