您的位置:首页 > 其它

面向对象的设计原则第一篇:Blacksmith的赢娶白富美的富强生活

2016-06-18 21:13 393 查看
//第一篇原则:贫穷的锻造师的励志故事(开播时间:16年6月18日晚上七点半)

//注意 以下代码均是讲解的最终版本,详细讲解内容,请关注直播 

     //好,我们继续开始讲解
     

      public  interface IBlacksmith
    {
        string Type_name { get; set; }

        void Blacksmith_show();

    }

        public class Armor:IBlacksmith
    {

    

   
        string _type_name;

        public Armor(string Type_name)
        {
            this.Type_name = _type_name;

        }

        public string Type_name
        {
            get
            {
                return _type_name;
            }

            set
            {
                _type_name = value;
            }
        }

        //   public void Armor_show()
        //  {
        //      Console.WriteLine("我是一件铠甲!!,我被锻造出来了");

        //  }

        public void Blacksmith_show()
        {
            Console.WriteLine("我是一件铠甲!!,我被锻造出来了");
        }

    }

    public class Sword:IBlacksmith
    {
        string _type_name;

        public Sword(string Type_name)
        {
            this.Type_name = _type_name;

        }

        public string Type_name
        {
            get
            {
                return _type_name;
            }

            set
            {
                _type_name = value;
            }
        }

        public void Blacksmith_show()
        {
            Console.WriteLine("我是一支大宝剑!!,我被锻造出来了,能卖伍佰元");
        }

       // public void Sword_show()
     //   {
     

       // }

    }

    public class Darksteel_meteorite_sword:IBlacksmith
    {
        string _type_name;

        public Darksteel_meteorite_sword(string Type_name)
        {
            this.Type_name = _type_name;

        }

        public string Type_name
        {     
            

        get
            {
             return _type_name;
            }

            set
            {
             _type_name = value;
            }
        }

        public void Blacksmith_show()
        {

            Console.WriteLine("我是独一无二的玄铁宝剑!!我被锻造出来了,能卖两千元");
        }
      //  public void Darksteel_meteorite_sword_show()
       // {
           

      //  }

    }

    public class fool_Blacksmith
    {
        //IQ不够,只会锻造铠甲
        public string name;
        

        public fool_Blacksmith(string name)
        {

            this.name = name;
     
        }

        public void fool_blacksmith_show(IBlacksmith ib)
        {
            Console.WriteLine("傻子锻造师:" + name + "又开始锻造了,当上CEO,走向人生巅峰,赢取白富美的生活到了");

            ib.Blacksmith_show();

        }

    }

    class City
    {
        static void Main(string[] args)
        {

            Sword sw = new Sword("大宝剑");
            Armor ar = new Armor("日炎铠甲");
            Darksteel_meteorite_sword dm = new Darksteel_meteorite_sword("玄铁大宝剑");

            fool_Blacksmith fb = new fool_Blacksmith("小强");

            fb.fool_blacksmith_show(sw);
            fb.fool_blacksmith_show(ar);
            fb.fool_blacksmith_show(dm);

            //这个时候,走过来一个人,让我们的傻子去打怪!
            //我们的傻子刚想打怪
            //程序员说了,我就是让你锻造装备的,不是让你打怪的,
            //总结完毕
            //今天课程就到这里
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息