program.cs

来自「大话设计模式源码bigtalkdesignpattern_src」· CS 代码 · 共 75 行

CS
75
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace 装饰模式
{
    class Program
    {
        static void Main(string[] args)
        {
            Person xc = new Person("小菜");

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

            xc.WearTShirts();
            xc.WearBigTrouser();
            xc.WearSneakers();
            xc.Show();

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

            xc.WearSuit();
            xc.WearTie();
            xc.WearLeatherShoes();
            xc.Show();

            Console.Read();
        }
    }

    class Person
    {
        private string name;
        public Person(string name)
        {
            this.name = name;
        }

        public void WearTShirts()
        {
            Console.Write("大T恤 ");
        }

        public void WearBigTrouser()
        {
            Console.Write("垮裤 ");
        }

        public void WearSneakers()
        {
            Console.Write("破球鞋 ");
        }

        public void WearSuit()
        {
            Console.Write("西装 ");
        }

        public void WearTie()
        {
            Console.Write("领带 ");
        }

        public void WearLeatherShoes()
        {
            Console.Write("皮鞋 ");
        }

        public void Show()
        {
            Console.WriteLine("装扮的{0}", name);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?