package com.codegym.task.task21.task2113;
import java.util.*;
public class Hippodrome {
private List<Horse> horses;
private Horse horse;
public static Hippodrome game;
public Hippodrome(){
}
public static void main(String[] args) throws InterruptedException{
List<Horse> horse = new ArrayList<>();
horse.add(new Horse("one", 3, 0));
horse.add(new Horse("two", 3, 0));
horse.add(new Horse("tre", 3, 0));
game = new Hippodrome(horse);
game.run();
}
public Hippodrome(List<Horse> horses){
this.horses = horses;
}
public Horse getWinner(){
Horse winner = null;
double distance = 0;
for(Horse h : horses){
if(h.getDistance() > distance){
winner = h;
distance = h.getDistance();
}
}
return winner;
}
public void printWinner(){
System.out.print("The winner is " + getWinner() + "!");
}
public List getHorses(){
List list = horses;
return list;
}
public void run() throws InterruptedException {
for(int i = 0; i < 100; i++){
move();
print();
Thread.sleep(200);
}
}
public void move(){
for(Horse h : horses){
h.move();
}
}
public void print(){
for(Horse h : horses){
h.print();
}
for(int i = 0; i < 10; i++){
System.out.println();
}
}
}