Beispiel #1
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.ReadKey();
        }
Beispiel #2
0
        private static void NewMethod1()
        {
            Person pr = new Person("Leng");

            Console.WriteLine("first look");

            Finery tShirts = new TShirts();

            tShirts.Show();
            Finery bigTrouser = new BigTrouser();

            bigTrouser.Show();
            Finery sneakers = new Sneakers();

            sneakers.Show();
            pr.Show();

            Console.WriteLine("\nsecond look");
            Finery suit = new Suit();

            suit.Show();
            Finery tie = new Tie();

            tie.Show();
            Finery leatherShoes = new LeatherShoes();

            leatherShoes.Show();
            pr.Show();

            Console.Read();
        }
Beispiel #3
0
        private static void NewMethod()
        {
            Person person = new Person("Leng");

            Console.WriteLine("first look");
            Sneakers   sneakers = new Sneakers();
            BigTrouser trouser  = new BigTrouser();
            TShirts    tShirts  = new TShirts();

            //Decoration process
            sneakers.Decorate(person);
            trouser.Decorate(sneakers);
            tShirts.Decorate(trouser);
            tShirts.Show();

            Console.WriteLine("\nsecond look");
            LeatherShoes leatherShoes = new LeatherShoes();
            Tie          tie          = new Tie();
            Suit         suit         = new Suit();

            //Decoration process
            leatherShoes.Decorate(person);
            tie.Decorate(leatherShoes);
            suit.Decorate(tie);
            suit.Show();

            Console.Read();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            #region 基本用法(对应Basic.cs)
            ConcreteComponent c = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            d1.SetComponent(c);
            d2.SetComponent(d1);

            d2.Operation();
            #endregion

            #region 具体实例(对应Example.cs)
            Person xc = new Person("小菜");
            Console.WriteLine("\n第一种装扮:");

            Sneaker pqx = new Sneaker();
            BigTrouser kk = new BigTrouser();
            TShirt dtx = new TShirt();

            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.ReadLine();
            #endregion
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            #region 基本用法(对应Basic.cs)
            ConcreteComponent  c  = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            d1.SetComponent(c);
            d2.SetComponent(d1);

            d2.Operation();
            #endregion

            #region 具体实例(对应Example.cs)
            Person xc = new Person("小菜");
            Console.WriteLine("\n第一种装扮:");

            Sneaker    pqx = new Sneaker();
            BigTrouser kk  = new BigTrouser();
            TShirt     dtx = new TShirt();

            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.ReadLine();
            #endregion
        }