static void Main(string[] args) { #region Lab_1 Directory directory = new Directory(); IBuilder b_1 = new Builder_1(); IBuilder b_2 = new Builder_2(); directory.Constructor(b_1); Product p_1 = b_1.GetResult(); p_1.Display(); directory.Constructor(b_2); Product p_2 = b_2.GetResult(); p_2.Display(); Console.ReadKey(); #endregion #region Lab_2 ProductDirectory directory_2 = new ProductDirectory(); ProductBuilder builder = new A_ProductBuilder(); directory_2.GenerateProduct(builder); var model = builder.GetModel(); Console.WriteLine(model.Id); Console.WriteLine(model.ProductName); Console.WriteLine(model.UnitPrice); Console.WriteLine(model.DiscountPrice); Console.WriteLine(model.DiscountedApplied); Console.ReadKey(); #endregion }
static void Main(string[] args) { #region SingletonPattern //Not: Lab uygulamalarında sınıfı, sınıf dışında new anahtar sözcüğü vasıtasıyla üretemeyiz. Bunun nedeni singleton ile bu nesneleri üreteceğimiz ve zaten bu bağlamda constructor private yaparak dış erişime kapattık ve singleton ile ters düşmedik. int toplam_1 = SingletonClass.Sınıf.Toplam(1, 2); Console.WriteLine(toplam_1); #endregion #region Lab_1_BuilderPattern ProductDirectory productDirectory = new ProductDirectory(); ProductBuilder productBuilder = new A_ProductBuilder(); productDirectory.UrunOlustur(productBuilder); var model = productBuilder.ModelAl(); Console.WriteLine(model.Id); Console.WriteLine(model.UrunAdi); Console.WriteLine(model.BirimFiyat); Console.WriteLine(model.IndirimliFiyat); Console.WriteLine(model.IndirimUygulmasi); #endregion #region Lab2_Hamburger Directory directory = new Directory(); IBuilder builder_1 = new Builder_1(); IBuilder builder_2 = new Builder_2(); directory.Yapim(builder_1); Product p_1 = builder_1.UrunuGetir(); p_1.Goruntule(); directory.Yapim(builder_2); Product p_2 = builder_2.UrunuGetir(); p_2.Goruntule(); #endregion Console.ReadKey(); }