Вроде все работает, а валидатор не принимает(
package com.javarush.task.task21.task2113;
import java.util.ArrayList;
import java.util.List;
public class Hippodrome {
private static ArrayList<Horse> hor = new ArrayList<>();
public static Hippodrome game;
public static void main(String[] args) {
game = new Hippodrome(hor);
game.getHorses().add(new Horse ("Лошадь-1", 3, 0));
game.getHorses().add(new Horse ("Лошадь-2", 3, 0));
game.getHorses().add(new Horse ("Лошадь-3", 3, 0));
game.run();
game.getWinner();
game.printWinner();
}
public Hippodrome(List horses){
this.horses = (ArrayList<Horse>) horses;
}
private ArrayList<Horse> horses;
public List<Horse> getHorses() {
return horses;
}
void run() {
for (int i = 0 ; i<100; i++){
move();
print();
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
void move(){
for(int i = 0; i< horses.size(); i++){
horses.get(i).move();
}
}
void print(){
for(int i = 0; i< horses.size(); i++){
horses.get(i).print();
}
for(int i = 0; i<10; i++){
System.out.println("");
}
}
public Horse getWinner() {
double maxDistance = 0;
Horse winner = null;
int id;
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()+"!");
}
}