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
26 lines (21 loc) · 628 Bytes
/
Race.java
File metadata and controls
26 lines (21 loc) · 628 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
public class Race {
public static String leader = "Car";
public static int distanceLeader = 0;
public static boolean flag = false;
public static void race (Car car) {
int loserDistance = car.speed * 24;
if (loserDistance > distanceLeader) {
leader = car.name;
distanceLeader = loserDistance;
} else if (distanceLeader == loserDistance) {
flag = true;
}
}
public static String Resuilt() {
if (flag) {
return "Ничья!";
} else {
return "Победитель: " + leader;
}
}
}