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
83 lines (72 loc) · 2.78 KB
/
Main.java
File metadata and controls
83 lines (72 loc) · 2.78 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// третья попытка
Race rc = new Race();
ArrayList<Car> carList = new ArrayList<>();
Scanner speedScan = new Scanner(System.in);
Scanner namesScan = new Scanner(System.in);
for (int i = 1; i < 4; i++) {
System.out.println("Введите имя машины номер " + i);
String model = namesScan.nextLine();
int kmh;
while (true) {
System.out.println("Введите скорость машины номер " + i);
kmh = speedScan.nextInt();
if (kmh <= 0 || kmh > 250) {
System.out.println("Неверная скорость");
} else {
break;
}
}
carList.add(new Car(kmh, model));
}
for (Car car : carList) {
rc.winRace(car.speed, car.name);
}
System.out.println("Самая быстрая машина: " + rc.winner);
}
}
/* вторая попытка
Car cars = new Car("",0);
Race race = new Race();
Scanner Nscan = new Scanner(System.in);
Scanner Sscan = new Scanner(System.in);
for (int i = 1; i<4; i++){
System.out.println("Введите имя машины номер "+ i );
String nameCar = Nscan.nextLine();
int speedCar;
while (true) {
System.out.println("Введите скорость машины номер " + i);
speedCar = Sscan.nextInt();
if (speedCar <= 0 || speedCar > 250) {
System.out.println("Неверная скорость");
} else {
break;
}
} race.win(speedCar,nameCar);
}
System.out.println("Самая быстрая машина: " + race.winner);
}
}*/
/* первая попытка
Car frstCar = new Car();
Car scndCar = new Car();
Car thrdCar = new Car();
System.out.println("Имя первой машины");
frstCar.setModel();
System.out.println("Скорость первой машины");
frstCar.setSpeed();
System.out.println("Имя второй машины");
scndCar.setModel();
System.out.println("Скорость второй машины");
scndCar.setSpeed();
System.out.println("Имя третьей машины");
thrdCar.setModel();
System.out.println("Скорость третьей машины");
thrdCar.setSpeed();
Race race = new Race();
race.win(frstCar.getSpeed(), scndCar.getSpeed(), thrdCar.getSpeed(), frstCar.getModel(), scndCar.getModel(), thrdCar.getModel());
}
}*/