コード例 #1
0
 public void AddSwimmer(Registrant swimmer)
 {
     if (!(AlreadyEntered(swimmer, CollOfRegisterants)))
     {
         swimmer.CollOfEvents.Add(this);
         CollOfRegisterants.Add(swimmer);
         CollOfSwims.Add(new Swim());
         NumOfRegisterant++;
         NumOfSwims++;
     }
     else
     {
         throw(new Exception(String.Format("Swimmer {0}, {1} is already entered", swimmer.Name, swimmer.RegistrationNumber)));
     }
 }
コード例 #2
0
        public void EnterSwimmersTime(Registrant swimmer, string time)
        {
            int indexOfSwimmerInCollection = 0;

            SwimTimeEntered = true;
            for (int i = 0; i < NumOfRegisterant; i++)
            {
                if (CollOfRegisterants[i] == swimmer)
                {
                    indexOfSwimmerInCollection = i;
                }
            }
            if (AlreadyEntered(swimmer, CollOfRegisterants) == true)
            {
                aSwimmer = (Swimmer)swimmer;
                CollOfSwims[indexOfSwimmerInCollection].TimeSwam = time;
                time = "0:" + time;
                aSwimmer.AddAsBestTime(PoolTypeOfEvent, Stroke, Distance, TimeSpan.Parse(time));
            }
            else
            {
                throw (new Exception("Swimmer has not entered the event"));
            }
        }
コード例 #3
0
 public void Add(Registrant registrant)
 {
     swimmers.Add(registrant);
     numberOfRegisterants++;
 }
コード例 #4
0
        private static void AssigneSwimmersToClubs(Registrant swimmer1, Registrant swimmer2, Registrant swimmer3, Club club1, Club club2)
        {
            Console.WriteLine("*******Adding swimmers to clubs ******\n***********************************");

            club1.AddSwimmer(swimmer1);
            DisplayInfo("club1", club1);
            DisplayInfo("swimmer1", swimmer1);

            club2.AddSwimmer(swimmer2);
            DisplayInfo("club2", club2);
            DisplayInfo("swimmer2", swimmer2);

            try
            {
                swimmer2.Club = club1;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                swimmer3.Club = club1;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            DisplayInfo("swimmer3", swimmer3);
            DisplayInfo("club1", club1);
        }
コード例 #5
0
        private static void AddSwimmersToEvents(Registrant swimmer1, Registrant swimmer2, Registrant swimmer3, SwimMeet meet1, SwimMeet meet2, Event _50free1, Event _100fly, Event _200breast, Event _400free, Event _1500free, Event _1500free2)
        {
            //Add swimmers to event
            _50free1.AddSwimmer(swimmer1);
            _50free1.AddSwimmer(swimmer2);
            _50free1.AddSwimmer(swimmer3);
            try
            {
                _50free1.AddSwimmer(swimmer3);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            _100fly.AddSwimmer(swimmer1);
            _100fly.AddSwimmer(swimmer2);

            _200breast.AddSwimmer(swimmer1);
            _200breast.AddSwimmer(swimmer2);
            _200breast.AddSwimmer(swimmer3);

            _400free.AddSwimmer(swimmer2);

            _1500free.AddSwimmer(swimmer1);
            _1500free.AddSwimmer(swimmer2);
            _1500free.AddSwimmer(swimmer3);

            _1500free2.AddSwimmer(swimmer1);
            _1500free2.AddSwimmer(swimmer3);

            DisplayInfo("meet1", meet1);
            DisplayInfo("meet2", meet2);
        }
コード例 #6
0
        private static void EnterTimesForSwims(Registrant swimmer1, Registrant swimmer2, Registrant swimmer3, SwimMeet meet1, SwimMeet meet2, Event _50free1, Event _100fly, Event _200breast, Event _400free, Event _1500free, Event _1500free2)
        {
            Console.WriteLine("********** Adding swim times for swimmers *********");

            _50free1.EnterSwimmersTime(swimmer1, "00:30.13");
            _50free1.EnterSwimmersTime(swimmer2, "00:28.87");
            _50free1.EnterSwimmersTime(swimmer3, "00:29.54");

            _100fly.EnterSwimmersTime(swimmer1, "01:17.23");
            _100fly.EnterSwimmersTime(swimmer2, "01:05.16");

            _200breast.EnterSwimmersTime(swimmer1, "02:25.23");
            _200breast.EnterSwimmersTime(swimmer3, "02:17.03");

            _400free.EnterSwimmersTime(swimmer2, "04:55.23");

            _1500free.EnterSwimmersTime(swimmer1, "15:17.23");
            _1500free.EnterSwimmersTime(swimmer2, "16:17.23");
            _1500free.EnterSwimmersTime(swimmer3, "17:17.23");

            _1500free2.EnterSwimmersTime(swimmer1, "15:16.23");
            _1500free2.EnterSwimmersTime(swimmer3, "17:18.23");

            try
            {
                _400free.EnterSwimmersTime(swimmer1, "04:55.23");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            DisplayInfo("meet1", meet1);
            DisplayInfo("meet2", meet2);
        }