Пример #1
0
        public void EnterSwimmersTime(Registrant registrant, string time)
        {
            int match = 0;

            for (int i = 0; i < this.NoOfRegistrantInEvent; i++)
            {
                if (EventRegistrantList[i] == registrant)
                {
                    EventRegistrantSwim[i].TimeSwam = time;
                    match++;
                }
            }
            if (match == 0)
            {
                throw new Exception(registrant.Name + " has not entered " + this.Name);
            }
        }
Пример #2
0
        private static void CreateSwimmers(out Registrant swimmer1, out Registrant swimmer2, out Registrant swimmer3)
        {
            swimmer1 = new Registrant("Bob Smith", new DateTime(1970, 1, 1),
                                      new Address("35 Elm St", "Toronto", "ON", "M2M 2M2"), 4161234567);
            DisplayInfo("swimmer1", swimmer1.GetInfo());

            swimmer2 = new Registrant();
            DisplayInfo("swimmer2", swimmer2.GetInfo());
            swimmer2.Address     = new Address("1 King St", "Toronto", "ON", "M2M 3M3");
            swimmer2.Name        = "John Lee";
            swimmer2.PhoneNumber = 4162222222;
            swimmer2.DateOfBirth = new DateTime(1950, 12, 1);
            DisplayInfo("swimmer2", swimmer2.GetInfo());

            swimmer3 = new Registrant("Ann Smith", new DateTime(1975, 1, 1),
                                      new Address("5 Queen St", "Toronto", "ON", "M2M 4M4"), 4163333333);
            DisplayInfo("swimmer3", swimmer3.GetInfo());
        }
Пример #3
0
 public void AddSwimmer(Registrant registrant)
 {
     Swims = new Swim();
     if (NoOfRegistrantInEvent > 0)
     {
         int match = 0;
         for (int i = 0; i < NoOfRegistrantInEvent; i++)
         {
             Registrant aRegistrantName = EventRegistrantList[i];
             if (aRegistrantName.Name == registrant.Name)
             {
                 match++;
                 throw new Exception("Swimmer " + registrant.Name + "," + registrant.RegistrationNumber + " already entered " + this.Name + "\n");
             }
         }
         if (match == 0)
         {
             EventRegistrantList[NoOfRegistrantInEvent] = registrant;
             EventRegistrantSwim[NoOfRegistrantInEvent] = Swims;
             if (NoOfRegistrantInEvent + 1 > SwimMeet.NumberOfLane)
             {
                 EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfLane     = 1;
                 EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfTheHeat += 1;
             }
             else
             {
                 EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfLane = NoOfRegistrantInEvent + 1;
             }
             NoOfRegistrantInEvent++;
         }
     }
     else
     {
         EventRegistrantList[NoOfRegistrantInEvent] = registrant;
         EventRegistrantSwim[NoOfRegistrantInEvent] = this.Swims;
         EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfLane = NoOfRegistrantInEvent + 1;
         NoOfRegistrantInEvent++;
     }
 }
Пример #4
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)
        {
            //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);

            DisplayInfo("meet1", meet1.GetInfo());
            DisplayInfo("meet2", meet2.GetInfo());
        }
Пример #5
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)
        {
            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");

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

            DisplayInfo("meet1", meet1.GetInfo());
            DisplayInfo("meet2", meet2.GetInfo());
        }
Пример #6
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.GetInfo());
            DisplayInfo("swimmer1", swimmer1.GetInfo());

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

            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.GetInfo());
            DisplayInfo("club1", club1.GetInfo());
        }
 public void AddSwimmer(Registrant registrant)
 {
     registrant.Club = this;
 }