forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
33 lines (28 loc) · 1.17 KB
/
Main.java
File metadata and controls
33 lines (28 loc) · 1.17 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
32
33
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String tmpName;
int tmpSpeed;
Race race = new Race();
System.out.println("Добро пожаловать в приложение «24 часа Ле-Мана»!");
for(int i = 0; i < 3; i++) {
System.out.println("Введите название машины №" + (i + 1));
tmpName = scanner.nextLine();
boolean isSpeedValid = false;
while(!isSpeedValid) {
System.out.println("Введите скорость машины №" + (i + 1));
tmpSpeed = scanner.nextInt();
if (tmpSpeed > 0 && tmpSpeed <= 250) {
Vehicle vehicle = new Vehicle(tmpName, tmpSpeed);
race.speedTest(vehicle);
isSpeedValid = true;
} else {
System.out.println("Недопустимая скорость");
}
scanner.nextLine(); //очистка буфера
}
}
race.printInfo();
}
}