import java.util.Scanner; public class Main { static Scanner scan=new Scanner(System.in); static int minSpeed=0; static int maxSpeed=250; public static void main(String[] args) { System.out.println("Ðвод ÑÑаÑÑников гонки:"); Race race=new Race(); for(int i=0;i<3;i++){ race.addCar(createCarFromKB(i+1)); } Car raceLeader=race.getLeader(); System.out.println("Ð¡Ð°Ð¼Ð°Ñ Ð±ÑÑÑÑÐ°Ñ Ð¼Ð°Ñина:"+raceLeader.name); } public static Car createCarFromKB(int carNumber){ System.out.println("ÐведиÑе название "+carNumber+"-го авÑомобилÑ"); if(carNumber>1){ scan.nextLine(); } String name = scan.nextLine(); int speed=inputCurrentSpeed("ÐведиÑе его ÑкоÑоÑÑÑ(Ð¾Ñ 0 до 250)"); return new Car(name,speed); } public static int inputCurrentSpeed(String mes){ System.out.println(mes); int speed; while (true) { if (scan.hasNextInt()) { speed = scan.nextInt(); if (speed < minSpeed || speed > maxSpeed) { System.out.println("ÐекоÑÑекÑÐ½Ð°Ñ ÑкоÑоÑÑÑ. ÐовÑоÑиÑе ввод"); } else { return speed; } } else { System.out.println("ÐÑибоÑнÑй ввод. ÐÑло введено не ÑиÑло. ÐовÑоÑиÑе ввод"); } } } }