See More

import java.util.Scanner; public class Auto { private String model; private int speed; public void inputAutoData() { Scanner console = new Scanner(System.in); System.out.println("Введите название автомобиля: "); model = console.nextLine(); while (model.isEmpty()) { System.out.println("Введено неверное значение."); System.out.println("Введите название автомобиля: "); model = console.nextLine(); } System.out.println("Введите скорость автомобиля (от 0 до 250): "); speed = console.nextInt(); while (speed < 0 || speed > 250) { System.out.println("Введено неверное значение."); System.out.println("Введите скорость автомобиля (от 0 до 250): "); speed = console.nextInt(); } } public String getModel() { return model; } public int getSpeed() { return speed; } }