//Makes a small burger with Ketchup and Pickles public static BurgerBuilder makeKidsBurger() { BurgerBuilder b = new BurgerBuilder(Size.small); b.AddKetchup().AddPickles(); return(b); }
//Requires an input of size //Makes a burger with cheese, lettuce, tomato, pickles, ketchup public static BurgerBuilder makeDeluxeBurger(Size size) { BurgerBuilder b = new BurgerBuilder(size); b.AddCheese().AddLettuce().AddTomato().AddPickles().AddKetchup(); return(b); }
private static void Main(string[] args) { //BUILDER PATTERN: //If you have a class with many options and a big constructor. Use builder pattern var burger = BurgerBuilder.Init(100) .WithCheese() .WithBacon() .Build(); //ADAPTER PATTERN: //An adapter pattern is used to combine 2 different classes //Scenerio: EmployeeManager can only return results in CSV, But we need in pipe seperated format IEmployeeManager adaptedInstance = new EmployeeAdapter(); var pipeSeperated = adaptedInstance.GetEmployess(); //FACADE PATTERN: //Facade pattern can be used for simplified entrys to sub systems (Many internal functions) var shoppingfacade = new ShoppingFacade(); shoppingfacade.BuyItem(); //DECORATOR PATTERN: //Usefull to extend new functions to a class without inheriting (or if sealed) var car = new BMW(); var discountedPrice = new DiscountCalculator(car).GetDiscountedPrice(); //FACTORY PATTERN: //Factory pattern helps build objects so client no need to know all concreate classes IInvoice invoice1 = InvoiceFactory.GetInvoice(1); IInvoice invoice2 = InvoiceFactory.GetInvoice(2); }
public static void ImplementBuilder() { var burger = new BurgerBuilder(); burger.addCheese(); burger.addPepperoni(); burger.build(); }
public Burger(BurgerBuilder builder) { this.mSize = builder.Size; this.mCheese = builder.Cheese; this.mPepperoni = builder.Pepperoni; this.mLettuce = builder.Lettuce; this.mTomato = builder.Tomato; }
public Burger(BurgerBuilder builder) { this.size = builder.size; this.cheese = builder.cheese; this.pepperoni = builder.pepperoni; this.lettuce = builder.lettuce; this.tomato = builder.tomato; }
public Burger(BurgerBuilder builder) { Size = builder.Size; Cheese = builder.Cheese; Pepperoni = builder.Pepperoni; Lettuce = builder.Lettuce; Tomato = builder.Tomato; }
public Burger(BurgerBuilder builder) { size = builder.size; cheese = builder.cheese; pepperoni = builder.pepperoni; lettuce = builder.lettuce; tomato = builder.tomato; }
public void Using() { var burger = new BurgerBuilder(14) .AddPepperoni() .AddLettuce() .AddTomato() .Build(); }
static void Main(string[] args) { var burger = new BurgerBuilder(4).AddCheese() .AddPepperoni() .AddLettuce() .AddTomato() .Build(); Console.WriteLine(burger.GetDescription()); Console.ReadLine(); }
static void Main(string[] args) { var burger = new BurgerBuilder(12) .AddPepperoni() .AddCheese() .AddLettuce() .AddTomato() .Build(); burger.PrintDetails(); Console.ReadKey(); }
static void Builder() { BurgerBuilder burger = new BurgerBuilder(14); burger.addPepperoni(); burger.addLettuce(); burger.addTomato(); // burger.addCheese(); Console.WriteLine("pepperoni " + burger.pepperoni); Console.WriteLine("lettuce " + burger.lettuce); Console.WriteLine("tomato " + burger.tomato); Console.WriteLine("cheese " + burger.cheese); }
public static void Run() { Log.Info("Builder Pattern"); var menu = new BreadMenu(); BurgerBuilder builder = new BurgerBuilder(); menu.Builder = builder; menu.BuildStandardOption(); menu.PrintIngredients(); menu.BuildTreatYourselfOption(); menu.PrintIngredients(); }
public static void Run() { Console.WriteLine("=-=-=-=Builder=-=-=-="); Console.WriteLine("BurgerBuilder"); _ = new BurgerBuilder(14) .AddPepperoni() .AddLettuce() .AddTomato() .Build(); Console.WriteLine("Burger: size 14, with pepperoni, lettuce and tomatos"); Console.WriteLine("----------------------------------" + Environment.NewLine); }
static void Main(string[] args) { Burger b1 = new BurgerBuilder(Size.large).AddCheese() .AddLettuce() .build(); Burger b2 = new BurgerBuilder(Size.small).build(); Burger b3 = new BurgerBuilder(Size.medium).AddTomato() .AddLettuce() .build(); Burger b4 = new Burger(SpecialtyBurgerFactory.makeDeluxeBurger(Size.large)); Burger b5 = new Burger(SpecialtyBurgerFactory.makeKidsCheeseBurger().AddPickles().AddMustard()); Console.WriteLine("Burger1:\n" + b1.ToString()); Console.WriteLine("Burger2:\n" + b2.ToString()); Console.WriteLine("Burger3:\n" + b3.ToString()); Console.WriteLine("Burger4:\n" + b4.ToString()); Console.WriteLine("Burger5:\n" + b5.ToString()); Console.Read(); }
static void Main(string[] args) { Burger burger = new BurgerBuilder(5) .AddPepperoni() .Build(); }
public BurgerDirector() { _burgerBuilder = new BurgerBuilder(); }
//################################################################################ #region Constructor public BurgerMaker(BurgerBuilder burgerBuilder) { m_BurgerBuilder = burgerBuilder; }