Пример #1
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);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Product product1 = new Product();

            product1.ProductId   = 1;
            product1.ProductName = "Elma";
            product1.Price       = 15;
            product1.Details     = "Amasya elması";

            Product product2 = new Product();

            product2.ProductId   = 2;
            product2.ProductName = "Karpuz";
            product2.Price       = 80;
            product2.Details     = "Diyarbakır karpuzu";

            Product product3 = new Product();

            product3.ProductId   = 3;
            product3.ProductName = "Patates";
            product3.Price       = 20;
            product3.Details     = "Afyonkarahisar patatesi";

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

            foreach (Product product in products)
            {
                Console.WriteLine(product.ProductName + " \n" + product.Details + " : " + product.Price);
                Console.WriteLine();
            }

            SepetManager sepetManager = new SepetManager();

            sepetManager.Add(product1);
            sepetManager.Remove(product1);
        }