import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Scanner;
public class Race {
ArrayList car = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
public void start() {
for (int i = 1; i <= 3; i++) {
String mark;
while (true) {
System.out.println("УкажиÑе название маÑÐ¸Ð½Ñ â" + i);
mark = scanner.next();
if (!mark.isEmpty()) {
break;
} else {
System.out.println("Ðазвание не подÑ
одиÑ, попÑобÑем дÑÑгое");
}
}
int speed;
while (true) {
System.out.println("УкажиÑе ÑкоÑоÑÑÑ Ð¼Ð°ÑÐ¸Ð½Ñ â" + i);
try {
speed = scanner.nextInt();
if ((speed > 0) && (speed <= 250)) {
break;
} else {
System.out.println("СкоÑоÑÑÑ Ð½Ðµ вÑ
Ð¾Ð´Ð¸Ñ Ð² диапазон Ð¾Ñ 0 до 250, попÑобÑйÑе Ñнова");
}
} catch (InputMismatchException e) {
System.out.println("УкажиÑе ÑкоÑоÑÑÑ Ð² ÑиÑловом ÑоÑмаÑе");
scanner.nextLine();
}
}
car.add(new Car(mark, speed));
System.out.println(mark + " ÐаÑина â" + i + " ÐµÐ´ÐµÑ Ñо ÑкоÑоÑÑÑÑ - " + speed);
}
}
public void finish() {
int firstCarDistance = car.get(0).speed *24;
int secondCarDistance = car.get(1).speed *24;
int thirdCarDistance = car.get(2).speed *24;
if (firstCarDistance > secondCarDistance && firstCarDistance > thirdCarDistance){
System.out.println(car.get(0).mark + " пÑоеÑ
ала - " + firstCarDistance + " км за 24 ÑаÑа и ÐÑйгÑала гонкÑ!");
} else if (secondCarDistance > firstCarDistance && secondCarDistance > thirdCarDistance){
System.out.println(car.get(1).mark + " пÑоеÑ
ала - " + secondCarDistance + " км за 24 ÑаÑа и ÐÑйгÑала гонкÑ!");
} else if(thirdCarDistance > firstCarDistance && thirdCarDistance > secondCarDistance){
System.out.println(car.get(2).mark + " пÑоеÑ
ала - " + thirdCarDistance + " км за 24 ÑаÑа и ÐÑйгÑала гонкÑ!");
} else{
System.out.println("Ð ÑÑÐ¾Ñ Ñаз на гонке Ð½ÐµÑ Ð¾Ð´Ð½Ð¾Ð³Ð¾ победиÑелÑ...");
}
}
}