Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("İnterfaces & Polymorphism Konu Anlatımı");
            Console.WriteLine("----------------------");

            #region 1-Interfaces Giriş
            Console.WriteLine("Interfaces Giriş");
            PersonManagerV1 managerV1 = new PersonManagerV1();

            Custormers1V personV1 = new Custormers1V
            {
                Id         = 1,
                FirstName  = "Ertuğrul",
                LastName   = "Doğancıoğlu",
                Departmant = "Computer Sciences"
            };

            Student1V studentV1 = new Student1V
            {
                //ctrl + space = Otamatik Propertleri gösterir.
                //ctrl + k ===> ctrl + d //// Kodları Düzeltir, Okunaklı Hale Getirir.
                //2 kere Tab Tab tuşuna basınca kodu otomatik tanımlar.
                Id        = 1,
                FirstName = "Gülnur",
                LastName  = "Doğancıoğlu",
                Adrees    = "Balıkesir"
            };

            managerV1.Add(studentV1);
            #endregion

            Console.WriteLine("----------------------");

            #region 2-Gerçek Hayatta Interface Kullanımı
            Console.WriteLine("Gerçek Hayat Örneği");
            CustomerManagerV2 customerMangerV2 = new CustomerManagerV2();
            customerMangerV2.Add(new SqlServerCustomerDalV2());
            #endregion

            Console.WriteLine("----------------------");

            #region 3-Polymorphism
            Console.WriteLine("Polymorphism");
            ICustomerDalV3[] customersDalsV3 = new ICustomerDalV3[2]
            {
                new SqlServerCustomerDalV3(),
                new OracleCustomerDalV3()
            };
            foreach (var item in customersDalsV3)
            {
                item.Add();
            }
            #endregion

            Console.WriteLine("----------------------");

            #region 4-Çoklu Implementasyon
            Console.WriteLine("Çoklu Implementasyon");
            IWorkerV4[] workersV4 = new IWorkerV4[3]
            {
                new ManagerV4(),
                new RobotV4(),
                new WorkerV4()
            };
            foreach (var item in workersV4)
            {
                item.Work();
            }

            //Robot Yemek Yemez
            IEatV4[] eatV4 = new IEatV4[2]
            {
                new ManagerV4(),
                new WorkerV4()
            };

            foreach (var item in eatV4)
            {
                item.Eat();
            }
            #endregion

            Console.ReadLine();
        }
Beispiel #2
0
 public void Add(ICustomerDalV3 customersDalV3)
 {
     customersDalV3.Add();
 }