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

            urun1.Adi      = "Elma";
            urun1.Fiyati   = 15;
            urun1.Aciklama = "Amasya Elması";

            Product urun2 = new Product();

            urun2.Adi      = "Karpuz";
            urun2.Fiyati   = 80;
            urun2.Aciklama = "Diyarbakır karpuzu";

            Product[] urunler = new Product[] { urun1, urun2 };

            foreach (var urun in urunler)
            {
                Console.WriteLine(urun.Adi);
                Console.WriteLine(urun.Fiyati);
                Console.WriteLine(urun.Aciklama);
                Console.WriteLine("-------------");
            }

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

            // instance - örnek
            // encapsulation

            SepetManager sepetManager = new SepetManager();

            sepetManager.Ekle(urun1);
            sepetManager.Ekle(urun2);

            sepetManager.Ekle2("Armut", "Yeşil Armut", 12, 10);
            sepetManager.Ekle2("Elma", "Yeşil Elma", 12, 9);
            sepetManager.Ekle2("Karpuz", "Diyarbakır Karpuzu", 12, 8);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string urunAdi  = "elma";
            double fiyat    = 15;
            string aciklama = "Amasya Elması";

            Product product1 = new Product();

            product1.Name        = "Elma";
            product1.Price       = 15;
            product1.Explanation = "Amasya Elması";

            Product product2 = new Product();

            product2.Name        = "Portakal";
            product2.Price       = 7;
            product2.Explanation = "Washington Portakalı";



            Product[] products = new Product[] { product1, product2 };

            foreach (Product product in products)
            {
                Console.WriteLine(product.Name);
                Console.WriteLine(product.Price);
                Console.WriteLine(product.Explanation);
                Console.WriteLine("--------------------");
            }

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

            SepetManager sepetManager = new SepetManager();

            sepetManager.Ekle(product1);
            sepetManager.Ekle(product2);
        }