import java.util.Scanner; public class Car { public String name; public int speed; Car(int pos) { Scanner scanner = new Scanner(System.in); System.out.println("ÐведиÑе название маÑÐ¸Ð½Ñ â" + pos); while (true) { this.name = scanner.nextLine(); if (!this.name.isEmpty()) { break; } else { System.out.println("ÐовÑоÑиÑе ввод, название не должно бÑÑÑ Ð¿ÑÑÑÑм!"); } } System.out.println("ÐведиÑе ÑкоÑоÑÑÑ Ð¼Ð°ÑÐ¸Ð½Ñ â " + pos + " (Ð¾Ñ 1 до 250 км/Ñ):"); while (true) { String speedS = scanner.nextLine().trim(); boolean speedOk; if (speedS.matches("\\d+")) { int speedI = Integer.parseInt(speedS); if (speedI>0 && speedI<=250) { speedOk = true; this.speed = speedI; } else { speedOk = false; } } else { speedOk = false; } if (speedOk) { break; } else { System.out.println("ÐовÑоÑиÑе ввод, ÑкоÑоÑÑÑ Ð´Ð¾Ð»Ð¶Ð½Ð° бÑÑÑ ÑелÑм ÑиÑлом Ð¾Ñ 1 до 250!"); } } } }