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
20 lines (17 loc) · 685 Bytes
/
Race.java
File metadata and controls
20 lines (17 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class Race {
private String leader = "";
private int leaderDistance = 0;
public void newLeaderUpdate(Auto auto) {
int distance = 24 * auto.speed;
if (distance> leaderDistance){
leaderDistance = distance;
leader = auto.name;
System.out.println("Новый лидер гонки: " + leader + " проехал дистанцию: " + leaderDistance + " км.");
} else {
System.out.println("Лидер по прежнему: " + leader + " проехал дистанцию: " + leaderDistance + " км.");
}
}
public String getCurrentLeader() {
return leader;
}
}