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 Lab_1 Directory directory = new Directory(); IBuilder builder_1 = new Builder_1(); IBuilder builder_2 = new Builder_2(); directory.Constructor(builder_1); Product product_1 = builder_1.GetResult(); product_1.Display(); directory.Constructor(builder_2); Product product_2 = builder_2.GetResult(); product_2.Display(); #endregion #region Lab_2 KrediKartiBuilder americanExpress = new AmericanExpress(); KrediKartiBuilder masterCart = new MasterCart(); KrediKartiBuilder visaCart = new VisaCart(); KartDirectory kartDirectory = new KartDirectory(); kartDirectory.KrediCartBuilder(americanExpress); KartDirectory kartDirectory2 = new KartDirectory(); kartDirectory.KrediCartBuilder(masterCart); KartDirectory kartDirectory3 = new KartDirectory(); kartDirectory.KrediCartBuilder(visaCart); Console.WriteLine(americanExpress.Kart.BankaAdi); Console.WriteLine(americanExpress.Kart.KartTipi); Console.WriteLine(americanExpress.Kart.KartLimiti); Console.WriteLine(americanExpress.Kart.TaksitAlma); Console.WriteLine("\n"); Console.WriteLine(masterCart.Kart.BankaAdi); Console.WriteLine(masterCart.Kart.KartTipi); Console.WriteLine(masterCart.Kart.KartLimiti); Console.WriteLine(masterCart.Kart.TaksitAlma); Console.WriteLine("\n"); Console.WriteLine(visaCart.Kart.BankaAdi); Console.WriteLine(visaCart.Kart.KartTipi); Console.WriteLine(visaCart.Kart.KartLimiti); Console.WriteLine(visaCart.Kart.TaksitAlma); #endregion Console.ReadKey(); }
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(); }