forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWheel.java
More file actions
26 lines (21 loc) · 789 Bytes
/
Wheel.java
File metadata and controls
26 lines (21 loc) · 789 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
import java.util.ArrayList;
public class Wheel {
ArrayList<Car> racers = new ArrayList<>();
public void checkWhoWinnerFrom() {
Car winner;
if (!(this.racers.isEmpty())) {
winner = this.racers.get(0);
for (Car challenger : racers) {
if (calculateDistance(challenger.speed) > calculateDistance(winner.speed)) {
winner = challenger;
}
}
System.out.println(String.format("%s оказалась самой быстрой машиной", winner.name));
} else {
System.out.println("Ошибка при расчете победителя");
}
}
public static int calculateDistance(int speed) {
return speed * 24;
}
}