3 пункт не проходит
package com.javarush.task.task21.task2113;
import java.util.ArrayList;
import java.util.List;
public class Hippodrome {
private List<Horse> horses;
static Hippodrome game;
public List<Horse> getHorses() {
return horses;
}
public Hippodrome(List<Horse> horses) {
this.horses = horses;
}
public static void main(String[] args) throws InterruptedException {
List<Horse> list = new ArrayList<>();
Horse horse1 = new Horse("horse1",3,0);
Horse horse2 = new Horse("horse2",3,0);
Horse horse3 = new Horse("horse2",3,0);
list.add(horse1);
list.add(horse2);
list.add(horse3);
game = new Hippodrome(list);
game.run();
game.getWinner();
game.printWinner();
}
public Horse getWinner(){
double maxDistance = Double.MIN_VALUE;
Horse horseWinner = new Horse(horses.get(0).name, horses.get(0).speed, maxDistance);
for (Horse horse : horses){
if (horse.distance > horseWinner.distance){
horseWinner.setName(horse.getName());
horseWinner.setSpeed(horse.getSpeed());
horseWinner.setDistance(horse.getDistance());
}
}
return horseWinner;
}
public void printWinner(){
Horse horse = getWinner();
System.out.println("Winner is "+horse.name+"!");
}
void run() throws InterruptedException {
for (int i = 1; i <= 100; i++) {
move();
print();
Thread.sleep(200);
}
}
void move(){
for (Horse horse : horses){
horse.move();
}
}
void print(){
for (Horse horse : horses){
horse.print();
}
for (int i = 0; i < 10; i++) {
System.out.println();
}
}
}