//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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public static void ImplementBuilder()
        {
            var burger = new BurgerBuilder();

            burger.addCheese();
            burger.addPepperoni();
            burger.build();
        }
예제 #5
0
 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;
 }
예제 #8
0
파일: Builder.cs 프로젝트: Digilad/Patterns
 public Burger(BurgerBuilder builder)
 {
     size      = builder.size;
     cheese    = builder.cheese;
     pepperoni = builder.pepperoni;
     lettuce   = builder.lettuce;
     tomato    = builder.tomato;
 }
예제 #9
0
파일: Builder.cs 프로젝트: Digilad/Patterns
 public void Using()
 {
     var burger = new BurgerBuilder(14)
                  .AddPepperoni()
                  .AddLettuce()
                  .AddTomato()
                  .Build();
 }
예제 #10
0
        static void Main(string[] args)
        {
            var burger = new BurgerBuilder(4).AddCheese()
                         .AddPepperoni()
                         .AddLettuce()
                         .AddTomato()
                         .Build();

            Console.WriteLine(burger.GetDescription());
            Console.ReadLine();
        }
예제 #11
0
        static void Main(string[] args)
        {
            var burger = new BurgerBuilder(12)
                         .AddPepperoni()
                         .AddCheese()
                         .AddLettuce()
                         .AddTomato()
                         .Build();

            burger.PrintDetails();

            Console.ReadKey();
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #15
0
        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();
        }
예제 #16
0
 static void Main(string[] args)
 {
     Burger burger = new BurgerBuilder(5)
                     .AddPepperoni()
                     .Build();
 }
예제 #17
0
 public BurgerDirector()
 {
     _burgerBuilder = new BurgerBuilder();
 }
예제 #18
0
        //################################################################################
        #region Constructor

        public BurgerMaker(BurgerBuilder burgerBuilder)
        {
            m_BurgerBuilder = burgerBuilder;
        }