1.简单工厂模式

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 简单工厂
{
class Program
{
static void Main(string[] args)
{
string tt= Console.ReadLine();
Notabook tb = Getbook(tt);
tb.Say();
Console.ReadKey();
} /// <summary>
/// 简单工厂核心,根据输入 创建对象赋值给父类~
/// </summary>
/// <param name="style"></param>
/// <returns></returns>
public static Notabook Getbook(string style)
{
Notabook tb = null;
switch(style)
{
case "lenvon":
tb=new lenvon();
break;
case "IBM":
tb = new IBM();
break;
case "DELL":
tb = new DELL();
break;
}
return tb;
}
} public abstract class Notabook
{
public abstract void Say();
} public class lenvon: Notabook
{
public override void Say()
{
Console.WriteLine("this is lenvon!");
}
} public class IBM:Notabook
{
public override void Say()
{
Console.WriteLine("this is IBM!");
}
} public class DELL:Notabook
{
public override void Say()
{
Console.WriteLine("this is DELL!");
}
}
}

C#面向对象17 23种设计模式的更多相关文章

  1. js实现23种设计模式(收藏)

    js实现23种设计模式 最近在学习面向对象的23种设计模式,使用java 和 javascript 实现了一遍,但是因为目前大三,还没有比较正规的大项目经验,所以学习的过程种我觉得如果没有一定的项目经 ...

  2. GOF提出的23种设计模式是哪些 设计模式有创建形、行为形、结构形三种类别 常用的Javascript中常用设计模式的其中17种 详解设计模式六大原则

    20151218mark 延伸扩展: -设计模式在很多语言PHP.JAVA.C#.C++.JS等都有各自的使用,但原理是相同的,比如JS常用的Javascript设计模式 -详解设计模式六大原则 设计 ...

  3. Java开发中的23种设计模式详解

    [放弃了原文访问者模式的Demo,自己写了一个新使用场景的Demo,加上了自己的理解] [源码地址:https://github.com/leon66666/DesignPattern] 一.设计模式 ...

  4. Java开发中的23种设计模式详解(转)

    设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...

  5. Java开发中的23种设计模式(转)

    设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...

  6. 23种设计模式全解析 (java版本)

    转自:http://blog.csdn.net/longyulu/article/details/9159589 其中PHP常用的五种设计模式分别为:工厂模式,单例模式,观察者模式,策略模式,命令模式 ...

  7. java 23 种设计模式

    一.设计模式的分类 总体来说设计模式分为三大类: 创建型模式,共五种:工厂方法模式.抽象工厂模式.单例模式.建造者模式.原型模式. 结构型模式,共七种:适配器模式.装饰器模式.代理模式.外观模式.桥接 ...

  8. (转)java 23种设计模式

    设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...

  9. Java编程的23种设计模式

    设计模式(Design Patterns)                                   --可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用. ...

随机推荐

  1. Nginx之 Location 的生成

    1. Location 的生成 location 的生成大致有三种: 由 location 指令直接生成 命令 location:仅用于 server 内部跳转,如 rewrite 就是命名 loca ...

  2. arcgis python desc.dataType

    desc = arcpy.Describe(r"C:\Users\dell\Documents\ArcGIS\ddd.shp") 是ShapeFile desc = arcpy.D ...

  3. MySQL 中<=>用法(长知识)

    https://www.runoob.com/mysql/mysql-operator.html MySQL 运算符 本章节我们主要介绍 MySQL 的运算符及运算符的优先级. MySQL 主要有以下 ...

  4. java调用exe,及调用bat不成功的解决办法

    开门见山的说,文件目录如下 想调用123.exe,但是尝试了几次调用不到,然后写了个bat.初始内容如下 @echo off D: cd test "123.exe" 双击可以运行 ...

  5. python pip 使用

    一.修改 pip 源 Windows 在用户目录下新建 pip\pip.ini 文件,如:C:\Users\Administrator\pip\pip.ini [global] index-url = ...

  6. LC 820. Short Encoding of Words

    Given a list of words, we may encode it by writing a reference string S and a list of indexes A. For ...

  7. xshell链接vbox 上 nat 方式链接虚拟机 - 端口转发

    使用场景 某些不可解原因导致 centos7通过桥接方式进行外网资源访问无法实现, 但是 nat 方式是没问题的, 因此考虑直接基于这个的方式进行操作, 但是xshell 的链接需要ip地址, 因此提 ...

  8. a lot of attention under the hood

    Because one of the original goals of the Node.js project was to allow developers to easily build app ...

  9. Go项目实战:打造高并发日志采集系统(二)

    日志统计系统的整体思路就是监控各个文件夹下的日志,实时获取日志写入内容并写入kafka队列,写入kafka队列可以在高并发时排队,而且达到了逻辑解耦合的目的.然后从kafka队列中读出数据,根据实际需 ...

  10. centos7安装kvm及kvm管理

    一.安装kvm 查看CPU是否支持虚拟化  grep -E 'svm|vmx' /proc/cpuinfo - vmx is for Intel processors - svm is for AMD ...