예제 #1
0
        public static void Main(string[] args)
        {
            #region Prototype

            Component component = new ConcreteComponent();
            Decorator decorator = new DecoratorA();
            decorator.SetComponent(component);
            decorator.Operation();

            Decorator decorator1 = new DecoratorB();
            decorator1.SetComponent(decorator);
            decorator1.Operation();

            #endregion Prototype

            var person = new Person("小明");

            Console.WriteLine("\n第一种装扮:\n");
            var pants = new Pants();
            pants.Decorate(person);
            pants.Show();

            Console.WriteLine("\n第二种装扮:\n");
            var shirts = new Tshirts();
            shirts.Decorate(pants);
            shirts.Show();

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Person xc      = new Person("小菜");
            Finery tShirt  = new Tshirts();
            Finery bigT    = new BigTrouser();
            Finery shoe    = new Shoes();
            Finery panties = new Panties();

            tShirt.Decorate(xc);
            bigT.Decorate(tShirt);
            shoe.Decorate(bigT);
            panties.Decorate(shoe);

            panties.Show();

            Console.ReadKey();
        }