Esempio n. 1
0
 public static Veterinarian getVeterinarian()
 {
     if (veterinarian == null)
     {
         veterinarian = new Veterinarian("Veterinarian");
     }
     return(veterinarian);
 }
Esempio n. 2
0
        public List <HorseInCompetition> runRace()
        {
            foreach (HorseInCompetition horse in horsers)
            {
                // перепрыгнула или нет?
                for (int j = 0; j < 6; j++)
                {
                    if (!jumpOverBarricade())
                    {
                        if (!jumpedAndNotSick())
                        {
                            horse.setState(new Sick());
                            horse.boardsPassed = j + 1;
                            break;
                        }
                        else
                        {
                            horse.raceResultTime += PENALTY_TIME;
                        }
                    }
                }
            }


            // Нахождение победителя
            HorseInCompetition fastestHorse = null;
            bool flag = false;

            foreach (HorseInCompetition horse in horsers)
            {
                if (horse.getState() is Sick)
                {
                    continue;
                }
                if (!flag)
                {
                    fastestHorse = horse;
                    flag         = true;
                }

                if (horse.raceResultTime < fastestHorse.raceResultTime)
                {
                    fastestHorse = horse;
                }
            }

            if (fastestHorse != null)
            {
                fastestHorse.setState(new Winner());
            }

            // Лечение лошадей
            Veterinarian veterinarian = Veterinarian.getVeterinarian();

            foreach (HorseInCompetition horse in horsers)
            {
                if (horse.getState() is Sick)
                {
                    veterinarian.treatment(horse);
                }
            }

            return(horsers);
        }