/*Enters Swimmers Time*/
        public void EnterSwimmersTime(Registrant registrant, string timeSwam)
        {
            try
            {
                int index = Swimmers.IndexOf(registrant);
                Swims[index].TimeSwam = timeSwam;
            }
            catch
            {
                throw new Exception(string.Format("Seed meets before entering time"));
            }

            Swimmer newSwimmer = registrant as Swimmer;

            if (newSwimmer != null)
            {
                int      min         = Int32.Parse(timeSwam.Substring(0, 2));
                int      sec         = Int32.Parse(timeSwam.Substring(3, 2));
                int      miliSec     = Int32.Parse(timeSwam.Substring(6, 2)) * 10;
                TimeSpan currentTime = new TimeSpan(0, 0, min, sec, miliSec);
                if (newSwimmer.BestTimeEvent.Count == 0)
                {
                    newSwimmer.BestTimeEvent.Add(this);
                    newSwimmer.BestTimeTimeSpan.Add(currentTime);
                }
                bool isAssigned = false;
                for (int i = 0; i < newSwimmer.BestTimeEvent.Count; i++)
                {
                    if (newSwimmer.BestTimeEvent[i].Stroke == this.Stroke &&
                        newSwimmer.BestTimeEvent[i].Distance == this.Distance &&
                        newSwimmer.BestTimeEvent[i].SwimMeets.Course == this.SwimMeets.Course)
                    {
                        if (TimeSpan.Compare(newSwimmer.BestTimeTimeSpan[i], currentTime) == 1)
                        {
                            newSwimmer.BestTimeTimeSpan[i] = currentTime;
                        }
                        isAssigned = false;
                        break;
                    }
                    else if (!isAssigned)
                    {
                        isAssigned = true;
                    }
                }
                if (isAssigned)
                {
                    newSwimmer.BestTimeEvent.Add(this);
                    newSwimmer.BestTimeTimeSpan.Add(currentTime);
                }
            }
        }
Exemplo n.º 2
0
 /*Add Swimemr Method*/
 public void AddSwimmer(Swimmer newSwimmer)
 {
     if (Club == newSwimmer.Club && !Swimmers.Contains(newSwimmer))
     {
         if (newSwimmer.Coach != this)
         {
             newSwimmer.Coach = this;
         }
         if (!Swimmers.Contains(newSwimmer))
         {
             Swimmers.Add(newSwimmer);
         }
     }
     else if (Club != newSwimmer.Club && Club != null)
     {
         throw new Exception("Coach and swimmer are in different club");
     }
     else if (Club == null)
     {
         throw new Exception("Coach is unassigned");
     }
 }