static void Main(string[] args)
        {
            var p    = new Parson("小菜");
            var bigT = new BigTrouser();
            var t    = new TShirts();
            var s    = new Sneaker();

            t.Decorate(p);
            s.Decorate(t);
            bigT.Decorate(s);
            bigT.Show();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Person xc = new Person("小菜");

            Console.WriteLine("\n第一种装扮:");

            Sneakers pqx = new Sneakers();
            BigTrouser kk = new BigTrouser();
            TShirts dtx = new TShirts();

            pqx.Decorate(xc);
            kk.Decorate(pqx);
            dtx.Decorate(kk);
            dtx.Show();

            Console.WriteLine("\n第二种装扮:");

            LeatherShoes px = new LeatherShoes();
            Tie ld = new Tie();
            Suit xz = new Suit();

            px.Decorate(xc);
            ld.Decorate(px);
            xz.Decorate(ld);
            xz.Show();

            Console.WriteLine("\n第三种装扮:");
            Sneakers pqx2 = new Sneakers();
            LeatherShoes px2 = new LeatherShoes();
            BigTrouser kk2 = new BigTrouser();
            Tie ld2 = new Tie();

            pqx2.Decorate(xc);
            px2.Decorate(pqx);
            kk2.Decorate(px2);
            ld2.Decorate(kk2);

            ld2.Show();

            Console.Read();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Person xc = new Person("小菜");

            Console.WriteLine("\n第一种装扮:");

            Sneakers   pqx = new Sneakers();
            BigTrouser kk  = new BigTrouser();
            TShirts    dtx = new TShirts();

            pqx.Decorate(xc);
            kk.Decorate(pqx);
            dtx.Decorate(kk);
            dtx.Show();

            Console.WriteLine("\n第二种装扮:");

            LeatherShoes px = new LeatherShoes();
            Tie          ld = new Tie();
            Suit         xz = new Suit();

            px.Decorate(xc);
            ld.Decorate(px);
            xz.Decorate(ld);
            xz.Show();

            Console.WriteLine("\n第三种装扮:");
            Sneakers     pqx2 = new Sneakers();
            LeatherShoes px2  = new LeatherShoes();
            BigTrouser   kk2  = new BigTrouser();
            Tie          ld2  = new Tie();

            pqx2.Decorate(xc);
            px2.Decorate(pqx);
            kk2.Decorate(px2);
            ld2.Decorate(kk2);

            ld2.Show();

            Console.Read();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            /*装饰的方法是:
             * 首先用ConcreteComponent实例化对象c
             * 然后用ConcreteDecorator的实例化对象来包装c
             * 最终执行c的Operation()
             */
            //ConcreteComponent c = new ConcreteComponent();
            //ConcreteDecorator d = new ConcreteDecorator();
            //d.SetComponent(c);
            //d.Operation();

            var zhangsan = new Person("张三");
            var tshirt   = new TShirts();
            var shorts   = new Shorts();

            //
            tshirt.Decorate(zhangsan);
            shorts.Decorate(tshirt);
            shorts.Show();

            Console.Read();
        }