static void Main(string[] args) { //string productName = "Apple"; //double price = 15; //Class bu uc bilgiyi bir urun nesnesi(elma) olarak anlatir soylenebilir. //string explanation = "Amasya apple"; //string[] fruits = new string[] { Apple,Watermelon }; //Tek tek yazmamiz gerekiyor boyle :( Product product1 = new Product(); product1.Name = "Apple"; product1.Price = 15; product1.Explanation = "Amasya Apple"; Product product2 = new Product(); product2.Name = "Watermelon"; product2.Price = 80; product2.Explanation = "Diyarbakir Watermelon"; Product[] products = new Product[] { product1, product2 }; //Type-safe -- tip guvenli foreach (var product in products) { Console.WriteLine(product.Name); Console.WriteLine(product.Price); Console.WriteLine(product.Explanation); Console.WriteLine("--------------------------------"); } Console.WriteLine("--------------Methods-----------------------"); //Instance -> class ornegi olusturma //Encapsulation BasketManager basketManager = new BasketManager(); basketManager.Add(product1); //Function Method is calling basketManager.Add(product2); basketManager.Add2("Grapes", "Green", 12, 10); basketManager.Add2("Apple", "Green apple", 12, 9); basketManager.Add2("WAtermelon", "Green", 12, 8); Console.ReadLine(); }
static void Main(string[] args) { Product product1 = new Product(); product1.Id = 1; product1.Name = "Elma"; product1.Price = 8; product1.Description = "Amasya Elması"; product1.Stock = 5; Product product2 = new Product(); product2.Id = 2; product2.Name = "Karpuz"; product2.Price = 80; product2.Description = "Diyarbakır Karpuzu"; product2.Stock = 15; Product[] products = new Product[] { product1, product2 }; //var da olur, C#'a sonradan girdi:) foreach (Product product in products) { Console.WriteLine(product.Name); Console.WriteLine(product.Price + " TL"); Console.WriteLine(product.Description); Console.WriteLine("----------------------------"); } Console.WriteLine("----------------Methodlar-----------------------"); //instance -örnek //encapsulation BasketManager basketManager = new BasketManager(); basketManager.Add(product1); basketManager.Add(product2); basketManager.Add2("Armut", "Yeşil Armut", 12, 20); basketManager.Add2("Kiraz", "Ekşi Kiraz", 20, 9); basketManager.Add2("Kavun", "Sulu Kavun", 30, 15); }
static void Main(string[] args) { string Name = "Elma"; double Price = 15; string Description = "Amasya elması"; string[] Fruits = new string[] { }; Product product1 = new Product(); product1.Name = "Elma"; product1.Price = 15; product1.Description = "Amasya Elması"; Product product2 = new Product(); product2.Name = "Karpuz"; product2.Price = 80; product2.Description = "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.Description); Console.WriteLine("------------------------------------------------------"); } Console.WriteLine("---------------------------Methods----------------------------"); //instance - Örnek //encapsulation -Kapsülleme Düzensiz bir yapıyı bir düzene sokma bir kapsüle sokma BasketManager basketManager = new BasketManager(); basketManager.Add(product1); basketManager.Add(product2); basketManager.Add2("Armut", "Sarı Armut", 12, 10); basketManager.Add2("Elma", "Yeşil Elma", 15, 8); basketManager.Add2("Karpuz", "Diyarbakır Karpuzu", 18, 9); //Ürünlerde bir düzenleme yapıldığında 2. yöntem sorun çıkarır. Bu yüzden metotlardan yararlanmak çok daha mantıklıdır }
static void Main(string[] args) { Product product1 = new Product(); product1.ProductName = "Fındık"; product1.UnitPrice = 23.45; product1.Explanation = "Giresun Kalite Fındık "; Product product2 = new Product(); product2.ProductName = "Karpuz"; product2.UnitPrice = 5.45; product2.Explanation = "Diyarbakır Karpuzu"; Product product3 = new Product(); product3.ProductName = "Çemen"; product3.UnitPrice = 12.23; product3.Explanation = "Meşhur Tokat Çemeni"; Product[] products = new Product[] { product1, product2, product3 }; foreach (Product product in products) { Console.WriteLine("Ürün Adı : " + product.ProductName); Console.WriteLine("Ürün Fiyatı : " + product.UnitPrice); Console.WriteLine("Açıklama : " + product.Explanation + "\n*********************"); } Console.WriteLine("\n***** Metotlar *******\n"); BasketManager basketManager = new BasketManager(); basketManager.Add(product1); basketManager.Add(product3); basketManager.Add2("Zeytin", 15, "Bursa Gemlik"); basketManager.Add2("Fıstık", 32, "Antep Fıstığı"); }
static void Main(string[] args) { Product product1 = new Product(); product1.Name = "Apple"; product1.Price = 15; product1.Detail = "Best Apple"; product1.stokAdedi = 20; Product product2 = new Product(); product2.Name = "Watermelon"; product2.Price = 80; product2.Detail = "Diyarbakir Watermelon"; Product[] products = new Product[] { product1, product2 }; //type-safe -- Tip güvenli foreach (var product in products) { Console.WriteLine(product.Name); Console.WriteLine(product.Price); Console.WriteLine(product.Detail); Console.WriteLine(product.stokAdedi); Console.WriteLine("--------"); } Console.WriteLine("----------------------Methods--------------"); //instance - örnek //reusability - tekrar kullanabilirlik //encapsulation BasketManager basketManager = new BasketManager(); basketManager.Add(product1); basketManager.Add(product2); basketManager.Add2("Armut", "Yeşil armut", 12, 10); basketManager.Add2("Elma", "Yeşil elma", 12, 9); basketManager.Add2("Karpuz", "Diyarbakır Karpuzu", 12, 8); }
static void Main(string[] args) { string Name = "Apple"; double Price = 15; string Definition = "Amasya apple"; string[] fruits = new string[] { "Apple", "Water melon" }; Product product1 = new Product(); product1.Name = "Apple"; product1.Price = 15; product1.Definition = "Amasya apple"; Product product2 = new Product(); product2.Name = "Water melon"; product2.Price = 80; product2.Definition = "Diyarbakır water melon"; Product[] products = new Product[] { product1, product2 }; foreach (Product product in products) { Console.WriteLine(product.Name); Console.WriteLine(product.Price); Console.WriteLine(product.Definition); Console.WriteLine("---------------"); } Console.WriteLine("----Methods-----"); BasketManager basketManager = new BasketManager(); basketManager.Add(product1); basketManager.Add(product2); basketManager.Add2("Pear", "Green pear", 12, 10); basketManager.Add2("Apple", "Green apple", 12, 9); basketManager.Add2("Water melon", "Diyarbakır water melon", 12, 8); }
static void Main(string[] args) { Product product1 = new Product(); product1.ProductName = "Apple"; product1.UnitPrice = 15; product1.QuantityPerUnit = "Just an Apple"; Product product2 = new Product(); product2.ProductName = "Watermelon"; product2.UnitPrice = 80; product2.QuantityPerUnit = "An Watermelon of Diyarbakir"; Product[] products = new Product[] { product1, product2 }; foreach (var product in products) { Console.WriteLine(product.ProductName); Console.WriteLine(product.UnitPrice); Console.WriteLine(product.QuantityPerUnit); Console.WriteLine("-----------------------"); } Console.WriteLine("\n------------METHODS------------"); // Instance: Örnek // ENCAPSULATION BasketManager basketManager = new BasketManager(); basketManager.Add1(product1); basketManager.Add1(product2); basketManager.Add2("Pear", "A green Pear", 12, 10); basketManager.Add2("Apple", "A green Apple", 14, 9); basketManager.Add2("Watermelon", "An Watermelon of Diyarbakir", 18, 8); }
static void Main(string[] args) { Product pro1 = new Product(); pro1.Name = "Elma"; pro1.Price = 15; pro1.Description = "Amasya elmasi"; Product pro2 = new Product(); pro2.Name = "Karpuz"; pro2.Price = 11; pro2.Description = "Diayrbakir karpuzu"; Product[] pros = new Product[] { pro1, pro2 }; foreach (var pro in pros) { Console.WriteLine(pro.Name); Console.WriteLine(pro.Price); Console.WriteLine(pro.Description); Console.WriteLine("----------------"); } Console.WriteLine("-----Methods-----------"); BasketManager basketmanager = new BasketManager(); basketmanager.Add(pro1); basketmanager.Add(pro2); basketmanager.Add2("Armut", "Sari Armut", 12, 8); basketmanager.Add2("Elma", "Sari elma", 12, 8); basketmanager.Add2("Karpuz", "Diyarbakir", 12, 8); }
static void Main(string[] args) { Product apple = new Product(); apple.productName = "Elma"; apple.price = 15; apple.Id = 1; apple.description = "Amasya Elması"; BasketManager manager = new BasketManager(); manager.Add(apple); manager.Add2("Armut", "İri Armut", 12); }
static void Main(string[] args) { if (args is null) { throw new ArgumentNullException(nameof(args)); } List <Product> products = new List <Product> { new Product { Id = 1, Name = "Apple", Price = 25, Description = "Apple of Amasya" }, new Product { Id = 1, Name = "Orange", Price = 25, Description = "Orange of Antalya" }, }; foreach (Product item in products) { Console.WriteLine(item.Name); Console.WriteLine(item.Price); Console.WriteLine(item.Description); Console.WriteLine("---------------------"); } Console.WriteLine("------------------Methods------------------"); //instance - örnek BasketManager basketManager = new BasketManager(); basketManager.Add(new Product { Name = "Apple" }); basketManager.Add(new Product { Name = "Orange" }); basketManager.Add2("Apple", "Apple of Amasya", 20); }
static void Main(string[] args) { Product product1 = new Product(); product1.Name = "Elma"; product1.Price = 7.5; product1.Explaining = "Amasya"; Product product2 = new Product(); product2.Name = "Kiraz"; product2.Price = 5.5; product2.Explaining = "Taze kiraz"; Product[] products = new Product[] { product1, product2 }; //for (int i = 0; i < products.Length; i++) //{ // Console.WriteLine(products[i].Price); //} //Console.WriteLine("**************"); foreach (var product in products) { Console.WriteLine(product.Name); Console.WriteLine(product.Price); Console.WriteLine(product.Explaining); Console.WriteLine("------------"); } Console.WriteLine("***** METHODS *****"); BasketManager basketManager = new BasketManager(); basketManager.Add(product1); basketManager.Add(product2); //Console.WriteLine(); // HATALI KULLANIMIN KODU; basketManager.Add2("Armut", "Yeşil Armut", 10); Console.ReadLine(); }