示例#1
0
 public Sandwhich(Bread topBread, CondimentList topCondiments, IngredientList ingredients,
                  CondimentList bottomCondiments, Bread bottomBread)
 {
     this.topBread         = topBread;
     this.topCondiments    = topCondiments;
     this.ingredients      = ingredients;
     this.bottomCondiments = bottomCondiments;
     this.bottomBread      = bottomBread;
 }
示例#2
0
        public static void Main()
        {
            var topBread      = new WheatBread();
            var topCondiments = new CondimentList(new List <ICondiment> {
                new MayoCondiment(), new MustardCondiment()
            });
            var ingredients = new IngredientList(new List <IIngredient> {
                new LettuceIngredient(), new ChickenIngredient()
            });
            var bottomCondiments = new CondimentList(new List <ICondiment> {
                new KetchupCondiment()
            });
            var bottomBread = new WheatBread();

            var sandwhich = new Sandwhich(topBread, topCondiments, ingredients, bottomCondiments, bottomBread);
            var context   = new Context();

            sandwhich.Interpret(context);
            Console.WriteLine(context.Output);
        }