Не принимает последний этап задачи, хотя все соответствует условию. Что может быть не так?
package com.javarush.task.task21.task2113;
import java.util.ArrayList;
import java.util.List;
public class Hippodrome {
public static Hippodrome game;
private List<Horse> horses;
public Hippodrome(List<Horse> horses) {
this.horses = horses;
}
public List<Horse> getHorses() {
return horses;
}
public void move() {
for (Horse horse : getHorses()) {
horse.move();
}
}
public void print() {
for (Horse horse : getHorses()) {
horse.print();
}
for (int i = 0; i < 10; i++) {
System.out.println();
}
}
public void run() throws InterruptedException {
for (int i = 0; i < 100; i++) {
move();
print();
Thread.sleep(200);
}
}
public Horse getWinner() {
double maxDistance = 0;
Horse winner = null;
for (Horse horse : getHorses()) {
if (horse.getDistance() > maxDistance) {
maxDistance = horse.getDistance();
winner = horse;
}
}
return winner;
}
public void printWinner() {
System.out.println("Winner is " + getWinner().getName() + "!");
}
public static void main (String[] args) throws InterruptedException {
Hippodrome.game = new Hippodrome(new ArrayList<Horse>());
game.getHorses().add(new Horse("horse1", 3, 0));
game.getHorses().add(new Horse("horse1", 3, 0));
game.getHorses().add(new Horse("horse3", 3, 0));
game.run();
game.printWinner();
}
}