forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRace.java
More file actions
27 lines (24 loc) · 825 Bytes
/
Race.java
File metadata and controls
27 lines (24 loc) · 825 Bytes
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
public class Race {
String leader;
int distance;
//Дистанция = время (24) * скорость
public int getDistance(int speed) {
distance = 24 * speed;
return speed;
}
public String checkLeader(Car carNumberOne,
Car carNumberTwo,
Car carNumberThree) {
int one = getDistance(carNumberOne.speed);
int two = getDistance(carNumberTwo.speed);
int three = getDistance(carNumberThree.speed);
if (one > two && one > three) {
leader = carNumberOne.name;
} else if (two > one && two > three) {
leader = carNumberTwo.name;
} else if (three > one && three > two) {
leader = carNumberThree.name;
}
return leader;
}
}