import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
ArrayList cars = carsRegistration();
System.out.println("ÐаÑÐ¸Ð½Ñ Ð·Ð°ÑегиÑÑÑиÑованÑ. Ðонка наÑинаеÑÑÑ!");
String winner = Race.distance(cars);
System.out.println("Ð¡Ð°Ð¼Ð°Ñ Ð±ÑÑÑÑÐ°Ñ Ð¼Ð°Ñина: " + winner);
}
public static ArrayList carsRegistration() {
Scanner scanner = new Scanner(System.in);
ArrayList cars = new ArrayList<>();
for (int i = 0; i < 3; i++) {
System.out.println("ÐведиÑе название маÑÐ¸Ð½Ñ â" + (i + 1));
String name = scanner.next();
while (true) {
try {
System.out.println("ÐведиÑе ÑкоÑоÑÑÑ Ð¼Ð°ÑÐ¸Ð½Ñ â" + (i + 1));
int speed = scanner.nextInt();
if (speed > 0 && speed <= 250) {
cars.add(new Car(name, speed));
Car newCar = cars.get(i);
System.out.println("ÐаÑина '" + newCar.name + "' Ñо ÑкоÑоÑÑÑÑ " + newCar.speed + " добавлена в гонкÑ");
break;
} else {
scanner.nextLine();
System.out.println("СкоÑоÑÑÑ Ð´Ð¾Ð»Ð¶Ð½Ð° бÑÑÑ Ð¾Ñ 0 до 250");
}
} catch (InputMismatchException e) {
scanner.nextLine();
System.out.println("ÐевеÑное знаÑение!");
}
}
}
return cars;
}
}