面向对象的设计原则第一篇: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); //这个时候,走过来一个人,让我们的傻子去打怪! //我们的傻子刚想打怪 //程序员说了,我就是让你锻造装备的,不是让你打怪的, //总结完毕 //今天课程就到这里
相关文章推荐
- 开发人员、程序员与计算机科学家三者之间的区别
- 一步一步跟我学易语言之第二个易程序菜单设计
- Lua编程示例(二):面向对象、metatable对表进行扩展
- C#中面向对象编程机制之多态学习笔记
- 浅谈Lua的面向对象特性
- Lua面向对象之类和继承浅析
- JavaScript面向对象的两种书写方法以及差别
- 浅谈c# 面向对象之类与对象
- C#面向对象特征的具体实现及作用详解
- C# 面向对象的基本原则
- 基于逻辑运算的简单权限系统(原理,设计,实现) VBS 版
- 浅谈对c# 面向对象的理解
- C#中设计、使用Fluent API
- Ruby面向对象编程详解
- C# 面向对象三大特性:封装、继承、多态
- 基于逻辑运算的简单权限系统(原理,设计,实现) VBS 版
- php学习 面向对象 课件第1/2页
- Lua中函数与面向对象编程的基础知识整理
- PHP程序61条面向对象分析设计的经验小结
- 收集学习asp.net比较完整的面向对象开发流程