예제 #1
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());
        }
예제 #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());
        }