Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            IndividualCustomer customer1 = new IndividualCustomer();

            customer1.Id             = 1;
            customer1.CustomerNumber = "222222";
            customer1.FirstName      = "Ferdi";
            customer1.LastName       = "Kaya";
            customer1.TcNo           = "22222222222";

            CorporateCustomer customer2 = new CorporateCustomer();

            customer2.Id             = 2;
            customer2.CustomerNumber = "1111";
            customer2.CompanyName    = "Kaya Holding";
            customer2.TaxNumber      = "343798134912";

            Customer customer3 = new IndividualCustomer();
            Customer customer4 = new CorporateCustomer();

            CustomerManager customerManager = new CustomerManager();

            customerManager.Add(customer1);
            customerManager.Add(customer3);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Customer musteri1 = new IndividualCustomer {
                Id = 1, CustomerNo = "123", Name = "Emre", Surname = "Polat", TcNo = "12345678910"
            };
            Customer musteri2 = new CorporateCustomer {
                Id = 2, CustomerNo = "234", CompanyName = "Firma", TaxNo = "23456"
            };

            CustomerManager musteriManager = new CustomerManager();

            musteriManager.PrintCustomerNo(musteri1);
            musteriManager.PrintCustomerNo(musteri2);

            Console.WriteLine(musteri2.CustomerNo); // Customer sınıfının özelliklerine erişemiyoruz bunun için alt satırdaki gibi yazabiliriz.
            Console.WriteLine(((CorporateCustomer)musteri2).CompanyName);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Creating customer Zack");
            Customer cust = new Customer(1, "zack");

            Console.WriteLine(cust.Say());
            cust.Do();

            Console.WriteLine("Creating customer Kyle");
            CorporateCustomer cCust = new CorporateCustomer(2, "Kyle", "WTW");

            Console.WriteLine(cCust.Say());
            cCust.Do();

            Console.WriteLine("Creating customer Bob");
            Customer cCust2 = new CorporateCustomer(3, "Bob", "Best Buy");

            // As you can see, method hiding does not make Say() use the CorporateCustomer's
            // Say() method, but overriding a virtual method WILL use the CorporateCustomer's
            // Do() method as shown.
            Console.WriteLine(cCust2.Say());
            cCust2.Do();
        }