static void Main(string[] args)
        {
            ISandwich sandwich1 = SandwichMaker
                                  .CreateSandwich(SandwichType.Bauru, true, true)
                                  .BuildSandwich()
                                  .GetSandwhich();

            sandwich1.Display();

            ISandwich sandwich2 = SandwichMaker
                                  .CreateSandwich(SandwichType.Chacarero, false, true)
                                  .BuildSandwich()
                                  .GetSandwhich();

            sandwich2.Display();

            ISandwich sandwich3 = SandwichMaker
                                  .CreateSandwich(SandwichType.Jambon)
                                  .BuildSandwich()
                                  .GetSandwhich();

            sandwich3.Display();

            Console.ReadLine();
        }
        public SandwichController(ISandwich sandwich)
        {
            // Totally contrived. Why would I do this? I wouldn't. I just needed something to demonstrate Ninject IoC working.
            sandwich.Description = "Deli Sandwich";
            sandwich.Id = 1;

            _sandwich = sandwich;
        }
        public ISandwich OrderSandwich(IList <string> ingredients)
        {
            ISandwich sandwich = _factory.CreateSandwich(ingredients);

            sandwich.Bake();
            sandwich.Cut();
            sandwich.Box();
            return(sandwich);
        }
Exemple #4
0
        public ISandwich OrderSandwich(IList <string> ingredients)
        {
            ISandwich pizza = CreateSandwich(ingredients);

            pizza.Bake();
            pizza.Cut();
            pizza.Box();
            return(pizza);
        }
Exemple #5
0
        public override ISandwich Serve()
        {
            ISandwich sandwich = Machine.Sandwich;

            Machine.Sandwich = null;
            Machine.Amount   = 0.0;
            Machine.Current  = Machine.BreadSelection;

            return sandwich;
        }
Exemple #6
0
        public ICondiment CreateCondiment(ISandwich aSandwich, string aType)
        {
            switch (aType)
            {
            case  "Butter": return(CreateButter(aSandwich));

            case  "Cheese": return(CreateCheese(aSandwich));

            case     "Ham": return(CreateHam(aSandwich));

            case "Lettuce": return(CreateLettuce(aSandwich));
            }
            return(null);
        }
        public void Create(ISandwich sandwich)
        {
            Console.WriteLine("\n\tMENU:");
            Console.WriteLine("Press 'C' to create recipe:");
            Console.WriteLine("Press 'I' to import recipe:");
            Console.WriteLine("Press 'D' to display recipe:");
            Console.WriteLine("Press 'E' to exit menu:");

            string choice;

            do
            {
                Console.WriteLine("\nUser choice:");
                choice = Console.ReadLine();

                switch (choice)
                {
                case "C":
                case "c":
                    sandwich.Create();
                    Console.WriteLine("\nRecipe is created");
                    break;

                case "I":
                case "i":
                    sandwich.ImportRecipe();
                    break;

                case "D":
                case "d":
                    DisplayRecipe();
                    Console.WriteLine();
                    break;

                case "E":
                case "e":
                    Console.WriteLine("\nExiting...");
                    break;

                default:
                    Console.WriteLine("Error: Please select C, I, D or E");
                    break;
                }
            }while (choice != "E");
        }
Exemple #8
0
        static void Main(string[] args)
        {
            SandwichMachine.Instance.SelectBread(nameof(WholeGrainBread));
            SandwichMachine.Instance.SelectCondiment("Butter");
            SandwichMachine.Instance.SelectCondiment("Cheese");
            SandwichMachine.Instance.SelectCondiment("Ham");
            SandwichMachine.Instance.SelectCondiment("Lettuce");
            SandwichMachine.Instance.Confirm();
            SandwichMachine.Instance.Pay(2.0);
            SandwichMachine.Instance.Pay(2.0);
            ISandwich sandwich = SandwichMachine.Instance.Serve();

            if (sandwich == null)
            {
                Console.WriteLine("Cannot serve the sandwitch");
            }
            else
            {
                Console.WriteLine(sandwich.Description + " = " + sandwich.GetPrice());
            }
            Console.ReadKey();
        }
Exemple #9
0
 public ICondiment       CreateHam(ISandwich aSandwich) => new Ham(aSandwich);
Exemple #10
0
 public ICondiment    CreateCheese(ISandwich aSandwich) => new Cheese(aSandwich);
Exemple #11
0
 public ICondiment    CreateButter(ISandwich aSandwich) => new Butter(aSandwich);
Exemple #12
0
 public MayonnaiseDecorator(ISandwich sandwich)
     : base(sandwich)
 {
     this.Description = description;
     this.Cost = cost;
 }
Exemple #13
0
 public SandwichDecorator(ISandwich sandwich, double price)
 {
     _sandwich = sandwich;
     _price    = price;
 }
Exemple #14
0
 public KetchupDecorator(ISandwich sandwich)
     : base(sandwich)
 {
     this.Description = description;
     this.Cost = cost;
 }
Exemple #15
0
 public Ham(ISandwich aSandwich)
 {
     Sandwich = aSandwich;
 }
Exemple #16
0
 public SandwichDecorator(ISandwich initSandwich)
 {
     this.sandwich = initSandwich;
 }
 public Cheese(ISandwich sandwich, double price)
     : base(sandwich, price)
 {
 }
 public Grilled(ISandwich sandwich, double price)
     : base(sandwich, price)
 {
 }
Exemple #19
0
 public Cheese(ISandwich aSandwich)
 {
     Sandwich = aSandwich;
 }
 public SandwichBuilder Reset()
 {
     Sandwich = new Sandwich();
     return(this);
 }
Exemple #21
0
 public ICondiment   CreateLettuce(ISandwich aSandwich) => new Lettuce(aSandwich);
Exemple #22
0
 public DonkeyBurger(ISandwich sandwich)
     : base(sandwich)
 {
     this.Description = description;
     this.Cost = cost;
 }
Exemple #23
0
 public Lettuce(ISandwich aSandwich)
 {
     Sandwich = aSandwich;
 }
 public SaltAndPepper(ISandwich sandwich)
 {
     _sandwich = sandwich;
 }
 public ExtraCheese(ISandwich sandwich)
 {
     _sandwich = sandwich;
 }
Exemple #26
0
 public Grilled(ISandwich sandwich)
 {
     _sandwich = sandwich;
 }
Exemple #27
0
 public Butter(ISandwich aSandwich)
 {
     Sandwich = aSandwich;
 }
Exemple #28
0
 public SandwichBuilderTwo(ISandwich sandwich)
 {
     _sandwich = sandwich;
 }
 public SandwichBuilderOne(ISandwich sandwich)
 {
     _sandwich = sandwich;
 }