Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string urunAdi1  = "Elma";
            double fiyati1   = 15;
            string aciklama1 = "Amasya Elması";

            string[] meyveler = new string[] { };


            Product product1 = new Product();

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

            Product product2 = new Product();

            product2.Adi      = "Karpuz";
            product2.Fiyati   = 80;
            product2.Aciklama = "Adana Karpuzu";

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



            foreach (var product in products) //in products(products dizisinin elamanlarını tek tek gez.(product) takma isim.(Product) çalışılacak veri tipi.
            {
                Console.WriteLine(product.Adi);
                Console.WriteLine(product.Fiyati);
                Console.WriteLine(product.Aciklama);
                Console.WriteLine("--------------------");
            }

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

            //instance - örnek

            //Encapsulation

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Yeşil armut", 12, 100);
            sepetManager.Add2("Elma", "Yeşil Elma", 12, 150);
            sepetManager.Add2("Karpuzt", "Adana Karpuzu", 12, 200);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

            product1.ProductName = "tavuk dürüm";
            product1.Id          = 1;
            product1.explanation = "hatay dürümü";
            product1.Price       = 10;

            Product product2 = new Product();

            product2.ProductName = "lahmacun";
            product2.Id          = 2;
            ;            product2.explanation = "çıtır çıtır";
            product2.Price = 7;

            Product[] Pruducts = new Product[] { product1, product2 };
            foreach (Product products in Pruducts)
            {
                Console.WriteLine(products.ProductName + "  " + products.explanation);
            }
            Console.WriteLine("----------Methods------------");
            //instance-örnek
            //encapsulation
            SepetManager sepetmanager = new SepetManager();

            sepetmanager.Add(product1);
            sepetmanager.Add(product2);
            sepetmanager.Add2(12, 1, "güzel", "elma", 7);
        }
Ejemplo n.º 3
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 (Product urun in urunler)
            {
                Console.WriteLine(urun.Adi);
                Console.WriteLine(urun.Fiyati);
                Console.WriteLine(urun.Aciklama);
                Console.WriteLine("-----------------------------");
            }
            Console.WriteLine("---------------Metotlar---------------");

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(urun1);
            sepetManager.Add(urun2);

            sepetManager.Add2("Armut", "Yesil Armut", 12);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //Dont repeat yourself - DRY - Clean Code - Best Practice

            Product product1 = new Product();

            product1.Name       = "Apple";
            product1.Price      = 15;
            product1.Definition = "Amasya Apple";

            Product product2 = new Product();

            product2.Name       = "Watermelon";
            product2.Price      = 80;
            product2.Definition = "Diyarbakir Watermelon";

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

            foreach (var allProduct in products)
            {
                Console.WriteLine(allProduct.Name + " : " + allProduct.Price + " : " + allProduct.Definition);
            }
            Console.WriteLine("-----------METHODS------------");

            //instance
            //cw = console.writeline -- prop = property getter setter yazar
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);
            sepetManager.Add2("Lemon", "Mersin Lemon", 15, 50);

            sepetManager.Remove(product1);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

            product1.ProductName        = "Elma";
            product1.ProductPrice       = 5;
            product1.ProductDescription = "Amasya elması";

            Product product2 = new Product();

            product2.ProductName        = "Karpuz";
            product2.ProductPrice       = 20;
            product2.ProductDescription = "Diyarbakır karpuzu";

            Product[] products = new Product[]
            {
                product1, product2
            };
            //type-safe==tip güvenliği
            foreach (Product product in products)
            {
                Console.WriteLine(product.ProductName);
                Console.WriteLine(product.ProductPrice);
                Console.WriteLine(product.ProductDescription);
                Console.WriteLine("------------------------");
            }
            Console.WriteLine("----------Methods---------------");
            //ıntance---class örneği oluşturma
            //encapsulation
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add2(1, "Kalem");
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            string productName = "Apple";
            double unitPrice   = 15;
            string description = "Amasya apple";


            string[] fruits = new string[] { "Apple", "Watermelon" };

            Product product1 = new Product();

            product1.ProductName = "Apple";
            product1.UnitPrice   = 15;
            product1.Description = "Amasya apple";

            Product product2 = new Product();

            product2.ProductName = "Watermelon";
            product2.UnitPrice   = 80;
            product2.Description = "Diyarbakır watermelon";

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

            //type-safe -- tip güvenli
            foreach (var product in products)   //2 kere dönücek 2 ürün var. urunler dizi, urun her bir elemanı tanımlamak için değişken
            {
                Console.WriteLine(product.ProductName);
                Console.WriteLine(product.UnitPrice);
                Console.WriteLine(product.Description);
                Console.WriteLine("--------------------");
            }

            Console.WriteLine("------------Methods---------------");
            //instance - örnek
            //encapsulation

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Pear", "Green pear", 12, 10);    //encapsulation- ayrı ayrı yazılanların bir düzene girmesi
            sepetManager.Add2("Apple", "Green apple", 12, 9);
            sepetManager.Add2("Watermelon", "Diyarbakır watermelon", 12, 8);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            string urunAdi  = "Elma";
            double fiyati   = 15;
            string aciklama = "Amasya elması";

            string[] meyveler = new string[] { "Elma", "Karpuz" };
            //class olduğu için productı newleriz.

            Product product1 = new Product();

            product1.Adi      = "Elma";
            product1.Fiyati   = 15;
            product1.Aciklama = "Amasya elması";

            Product product2 = new Product();

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

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

            //type-safe -- tip güvenli ne ile çalışacağını bilmek ister, product burada tip verir
            // var ürünü direkt product tipi yapar.
            foreach (Product product in products) // her elemanı tek tek gez ve ekrana yazdır.
            {
                // normalde htmlde mesela <li> {}<li> gibi yazılır
                // cw programcı yazı aracıdır.  program içinde kullanılmaz normalde. dil yazanın ne çıkacağını görmesi işine yarar.
                Console.WriteLine(product.Adi);
                Console.WriteLine(product.Aciklama);
                Console.WriteLine(product.Fiyati);
                Console.WriteLine("-------------------------");
            }



            // genellikle bu productlar bir veri kaynağından gelir.

            // classla da array oluşturabiliriz.

            Console.WriteLine("----------Methods------------");
            //instance- class örneği ulaştırmak.
            //encapsulation = kapsülleme demektir.

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Yeşil armut", 12);

            Console.WriteLine("Hello World!");
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            Product product01 = new Product();

            product01.Name        = "Elma";
            product01.Price       = 15;
            product01.Explanation = "Amasya elması";

            Product product02 = new Product();

            product02.Name        = "Karpuz";
            product02.Price       = 80;
            product02.Explanation = "Diyarbakır karpuzu";

            Product[] products = new Product[] { product01, product02 };

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

            Console.WriteLine("/*/*/*/*/*/ METHODS /*/*/*/*/*/\n");

            // instance - örnek
            // encapsulation - kapsülleme
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product01);
            sepetManager.Add(product02);

            /* sepetManager Add2'ye parametre eklendiğinde burası patlar,
             * bu yüzden ürünleri class içinde tanımlamak daha doğrudur!!!
             */
            sepetManager.Add2("Armut", "Yeşil armut", 12, 10);
            sepetManager.Add2("Elma", "Yeşil elma", 12, 9);
            sepetManager.Add2("Karpuz", "Diy.Karpuzu", 12, 8);
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

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

            Product product2 = new Product();

            product2.Name        = "Karpuz";
            product2.Price       = 80;
            product2.Explanation = "Diyarbakır Karpuzu";

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

            //type-safe -- tip güvenliği

            foreach (Product product in products)
            {
                Console.WriteLine("Ürün Adı: " + product.Name);
                Console.WriteLine("Fiyatı: " + product.Price);
                Console.WriteLine(product.Explanation);
                Console.WriteLine("*********************");
            }

            Console.WriteLine("---------------Methods-----------------");
            //instance -- Class örneği oluşturmak
            //encapsulation

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);
            //Aşağıdaki yanlış kullanım örneği
            sepetManager.Add2("Armut", "Yeşil Armut", 12, 10);
            sepetManager.Add2("Elma", "Yeşil Elma", 12, 9);
            sepetManager.Add2("Karpuz", "Diyarbakır Karpuzu", 12, 8);
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Product prod1 = new Product();

            prod1.Name        = "Elma";
            prod1.Price       = 15;
            prod1.Description = "Amasya Elması";

            Product prod2 = new Product();

            prod2.Name        = "Karpuz";
            prod2.Price       = 80;
            prod2.Description = "Diyarbakır Karpuzu";

            Product[] products = new Product[] { prod1, prod2 };


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

            Console.WriteLine("--------------Methods---------------");
            //instance
            //encapsulation
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(prod1);
            sepetManager.Add(prod2);



            sepetManager.Add2("Armut", "Yeşil Armut", 12, 58);
            sepetManager.Add2("Elma", "Yeşil Elma", 12, 85);
            sepetManager.Add2("Karpuz", "Diyarbakır Karpuzu", 20, 15);
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            string productName = "Apple";
            double price       = 12;
            string explanation = "Red Apple";

            Product product1 = new Product();

            product1.Name        = "Apple";
            product1.Price       = 15;
            product1.Explanation = "Red Apple";

            Product product2 = new Product();

            product2.Name        = "Watermelon";
            product2.Price       = 18;
            product2.Explanation = "Diyarbakır Watermelon";

            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("************Methods*************");

            //instance - örnek
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Apple", "Green Apple", 12, 10);
            sepetManager.Add2("Apple-2", "Red Apple-2", 15, 20);
        }
        static void Main(string[] args)
        {
            Product product1 = new Product();

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

            Product product2 = new Product();

            product2.Name   = "Karpuz";
            product2.Price  = 80;
            product2.Detail = "Diyarbakır Karpuzu";

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

            // type-safe -- tip güvenli
            foreach (Product product in products)
            {
                Console.WriteLine("Ürünün İsmi : " + product.Name);
                Console.WriteLine("Ürünün Fiyatı : " + product.Price);
                Console.WriteLine("Ürün Açıklaması : " + product.Detail);
                Console.WriteLine("---------------");
            }

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

            //instance - örnek
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

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

            sepetManager.Add2("Armut", "Yeşil Armut", 13, 9);
            sepetManager.Add2("Elma", "Yeşil Elma", 14, 12);
            sepetManager.Add2("Karpuz", "Diyarbakır Karpuzu", 50, 7);
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            //string urunAdi = "Elma";
            //double fiyat = 10;   DUZENSIZ BIR GOSTERIM DIZI KULLANMAK DAHA MANTIKLI
            //string aciklama = "Amasya Elmasi";

            string[] meyveler = new string[] { "Elma", "Muz" };
            Product  product1 = new Product();

            product1.Adi      = "Elma";
            product1.Fiyati   = 15;
            product1.Aciklama = "Amasya Elmasi";

            Product product2 = new Product();

            product2.Adi      = "Muz";
            product2.Fiyati   = 30;
            product2.Aciklama = "Yerli muz";

            Product[] products = new Product[] { product1, product2 };
            foreach (Product product in products)
            {
                Console.WriteLine(product.Adi);
                Console.WriteLine(product.Fiyati);
                Console.WriteLine(product.Aciklama);
                Console.WriteLine("---------------------------");
            }
            Console.WriteLine("------------METHODS--------------");

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Yesil armut", 12, 10);
            sepetManager.Add2("Elma", "Yesil elma", 10, 9);
            sepetManager.Add2("Karpuz", "Cekirdeksiz Karpuz", 80, 8);
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

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

            Product product2 = new Product();

            product2.Adi      = "Karpuz";
            product2.Fiyati   = 80;
            product2.Aciklama = "Diyarbakır Karpuzu";

            Product[] products = new Product[] { product1, product2 };
            //type-safe
            foreach (Product product in products)
            {
                Console.WriteLine(product.Adi);
                Console.WriteLine(product.Fiyati);
                Console.WriteLine(product.Aciklama);
                Console.WriteLine("---------------------------");
            }

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


            //instance
            //encapsulation
            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Yeşil Armut", 12, 10);
            sepetManager.Add2("Elma", "Yeşil Elma", 12, 9);
            sepetManager.Add2("Karpuz", "D.Bakır Karpuzu", 12, 8);
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

            product1.Id    = 1;
            product1.Name  = "Telefon";
            product1.Price = 5000;

            Product product2 = new Product();

            product2.Id    = 2;
            product2.Name  = "Bilgisayar";
            product2.Price = 10000;

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

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

            Console.WriteLine("----------------Methods----------------");
            //Instance - Örnek
            //Encapsulation - Bir şeyi düzenli bir şekilde yazma/kapsülleme olayı

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Bisiklet", "Mavi bisiklet", 500);
            sepetManager.Add2("Tost Makinası", "tost makinası", 300);

            Console.ReadLine();
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

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

            Product product2 = new Product();

            product2.Name   = "Karpuz";
            product2.Price  = 80;
            product2.Detail = "Diyarbakır karpuzu";

            Product[] products = new Product[] { product1, product2 };
            foreach (Product product in products)
            {
                Console.WriteLine(product.Name);
                Console.WriteLine(product.Price);
                Console.WriteLine(product.Detail);
                Console.WriteLine("-----------");
            }

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

            //instance -örnek oluşturma
            //encapsulation

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Yeşil Armut", 12, 10);
            sepetManager.Add2("Elma", "Yeşil Elma", 12, 9);
            sepetManager.Add2("Karpuz", "Diyarbakır Karpuzu", 12, 8);
        }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

            product1.Name        = "Elma";
            product1.Cost        = 3.95;
            product1.Explanation = "Amasya Elması";

            Product product2 = new Product();

            product2.Name        = "Karpuz";
            product2.Cost        = 16.9;
            product2.Explanation = "Diyarbakır Karpuzu";

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

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

            Console.WriteLine("----------------Methods-------------");
            //encapsulation

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Ankara", 5.49, 26);
            sepetManager.Add2("Erik", "Can", 8.75, 4);
            sepetManager.Add2("Muz", "İthal", 12.5, 16);
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            string ProductName = "Elma";
            double Price       = 15;
            string Detail      = "Amasya elmasi";

            string[] Meyveler = new string[] { };

            Product product1 = new Product();

            product1.Name   = "Elma";
            product1.Id     = 1;
            product1.Price  = 12;
            product1.Detail = "Amasya elmasi";

            Product product2 = new Product();

            product2.Name   = "Karpuz";
            product2.Id     = 2;
            product2.Price  = 3;
            product2.Detail = "Diyarbakir karpuzu";

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

            foreach (var product in products)
            {
                Console.WriteLine("Urun adi : " + product.Name);
            }

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

            SepetManager sepetManager = new SepetManager();


            foreach (var product in products)
            {
                sepetManager.Add(product);
            }

            sepetManager.Add2(3, "Armut", 6.55, "Koy armudu");
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            string productName = "Elma";
            double price       = 15;
            string description = "Amasya Elması";


            string[] meyveler = new string[] { };

            Product urun1 = new Product();

            urun1.Name        = "Elma";
            urun1.Price       = 15;
            urun1.Description = "Amasya Elması";

            Product urun2 = new Product();

            urun2.Name        = "Karpuz";
            urun2.Price       = 80;
            urun2.Description = "Diyarbakır karpuzu";

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

            foreach (Product urun in urunler)
            {
                Console.WriteLine(urun.Name);
                Console.WriteLine(urun.Price);
                Console.WriteLine(urun.Description);
                Console.WriteLine(" ");
            }


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

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(urun1);
            sepetManager.Add(urun2);

            sepetManager.Add2("Armut", 12, "Yeşil Armut");
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            //Class olduğu için newlemek lazım

            Product product1 = new Product();

            product1.ProductName = "Apple";
            product1.Price       = 15;
            product1.Description = "Apple of Amasya";

            Product product2 = new Product();

            product2.ProductName = "Watermelon";
            product2.Price       = 80;
            product2.Description = "Diyarbakır Karpuzu";

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

            //Type safe -- tip güvenli
            foreach (Product product in products)
            {
                Console.WriteLine(product.ProductName);
                Console.WriteLine(product.Price);
                Console.WriteLine(product.Description);
                Console.WriteLine("****************************");
            }


            Console.WriteLine("********************Metotlar****************");
            //instance - örnek
            //encapsulation

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);


            sepetManager.Add2("Armut", "Yeşil armut", 12, 5);
        }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            Products product1 = new Products();

            product1.Name        = "elma";
            product1.Price       = 15;
            product1.Description = "Amasya Elması";
            product1.Stock       = 1200;

            Products product2 = new Products();

            product2.Name        = "Karpuz";
            product2.Price       = 80;
            product2.Description = "Diyarbakır Karpuzu";
            product2.Stock       = 100

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

            //type-safe -- tip güvenli
            foreach (Products product in products)
            {
                Console.WriteLine(product.Name);
                Console.WriteLine(product.Price);
                Console.WriteLine(product.Description);
            }

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

            //instance -- örnek

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Add(product2);

            sepetManager.Add2("Armut", "Yeşil Armut", 12);
        }