forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
31 lines (28 loc) · 1.12 KB
/
Main.java
File metadata and controls
31 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Race race = new Race();
for (int i = 0; i < 3; i++) {
System.out.println("Введите название авто " + (i + 1) + ":");
String name = scanner.next();
int speed;
while (true) {
System.out.println("Введите скорость авто " + (i + 1) + " от 0 до 250км/ч");
speed = scanner.nextInt();
if (speed <= 250) {
if (speed >= 0) {
break;
} else {
System.out.println("Скорость авто введена неправильно.Повторите ещё раз");
scanner.nextInt();
}
}
}
Car car = new Car(name, speed);
race.updateLeader(car);
}
System.out.println("Победитель на машине - " + race.getLeader());
scanner.close();
}
}