using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace BuilderModel

{

public class Bike

{

private int wheels;

public int Wheels         {             get { return wheels; }             set { wheels = value; }         }

private int frams;

public int Frams         {             get { return frams; }             set { frams = value; }         }

}

}

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace BuilderModel

{    public abstract class BuilderBike

{        public abstract void BuilWheels(int wheeels);        public abstract void Buildframs(int frams);

public abstract Bike getBike();

}

}

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace BuilderModel

{

public class ConsBike:BuilderBike

{

Bike bike = new Bike();

public override Bike getBike()

{

return bike;

}

public override void BuilWheels(int wheels)

{

bike.Wheels = wheels;

}

public override void Buildframs(int frams)

{

bike.Frams = frams;

}

}

}

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace BuilderModel

{

public class DireBike

{

public void CreateBike(BuilderBike buildBike)

{

buildBike.Buildframs(1);

buildBike.BuilWheels(2);

}

}

}

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace BuilderModel

{

class Program

{

static void Main(string[] args)

{       BuilderBike buildBike = new ConsBike();

DireBike dirBike = new DireBike();

dirBike.CreateBike(buildBike);

Bike bike= buildBike.getBike();

Console.WriteLine("自行车的轮自有wheels="+bike.Wheels+"个"+"\t"+"架子frams="+bike.Frams+"个");

Console.ReadKey();

}

}

}

设计模式-生成者模式之c#代码的更多相关文章

  1. 设计模式学习--组合模式,c++代码

    下面是组合模式的UML类图: <span style="font-family:Microsoft YaHei;font-size:18px;"><span st ...

  2. js设计模式——1.代理模式

    js设计模式——1.代理模式 以下是代码示例 /*js设计模式——代理模式*/ class ReadImg { constructor(fileName) { this.fileName = file ...

  3. python设计模式之模板模式

    python设计模式之模板模式 编写优秀代码的一个要素是避免冗余.在面向对象编程中,方法和函数是我们用来避免编写冗余代码的重要工具. 现实中,我们没法始终写出100%通用的代码.许多算法都有一些(但并 ...

  4. js设计模式——5.状态模式

    js设计模式——5.状态模式 代码演示 /*js设计模式——状态模式*/ // 状态(红灯,黄灯,绿灯) class State { constructor(color) { this.color = ...

  5. 设计模式之策略模式(iOS开发,代码用Objective-C展示)

    在实际开发过程中,app需求都是由产品那边给出,往往是他给出第一版功能,我们写好代码后,会相应的给出第二版.第三版功能,而这些功能是在实际使用中,根据用户需求而不断增加的.如果在编码之初,我们并未认识 ...

  6. 设计模式入门,策略模式,c++代码实现

    // test01.cpp : Defines the entry point for the console application.////第一章,设计模式入门,策略模式#include &quo ...

  7. 每天一个设计模式-2 外观模式(Facade)

    每天一个设计模式-2  外观模式(Facade) 1.生活中的示例 客户想要购买一台电脑,一般有两种方法: 1.自己DIY,客户需要知道组成电脑的所有电子器件,并且需要熟悉那些配件,对客户要求较高. ...

  8. 设计模式——抽象工厂模式及java实现

    设计模式--抽象工厂模式及java实现 设计模式在大型软件工程中很重要,软件工程中采用了优秀的设计模式有利于代码维护,方便日后更改和添加功能. 设计模式有很多,而且也随着时间在不断增多,其中最著名的是 ...

  9. Java设计模式——装饰者模式

    JAVA 设计模式 装饰者模式 用途 装饰者模式 (Decorator) 动态地给一个对象添加一些额外的职责.就增加功能来说,Decorator 模式相比生成子类更为灵活. 装饰者模式是一种结构式模式 ...

随机推荐

  1. 用python登录远程salt,并执行命令

    用python操作saltstack,如果是在本地,则可以用python的salt模块,但如果要操作远程saltstack,则不行,今天就来看看怎么操作. 用python操作远程的saltstack, ...

  2. 解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办

    解决 php 报错 open_basedir restriction in effect或者nginx提示No input file specified怎么办 问题是出现在了PHP.INI上面了 ,原 ...

  3. socket 网络连接基础

    socket 客户端 import socket 1.client = socket.socket()  # socket.TCP/IP 选择连接的类型,默认为本地连接 2.client.connec ...

  4. jetty异常

    异常一: java.net.BindException: Address already in use: bind jvm 1 | 2017-10-18 15:08:10,792+0800 WARN ...

  5. UI5-文档-4.2-Bootstrap

    在使用SAPUI5做一些事情之前,我们需要加载并初始化它.加载和初始化SAPUI5的过程称为引导.一旦引导完成,我们只需显示一个警告. Preview An alert "UI5 is re ...

  6. CSS选择器学习小结

    关于CSS选择器的问题,在实际项目中,以及一般的前端面试中会经常遇到.下面对此做一小结,梳理和巩固相关方面知识.(如有不妥之处,还望大家及时批评指正,以免误导他人) 一.选择器种类 1.id选择器(# ...

  7. 锋利的BFC

    在初学前端的时候,我们会经常碰到各种各样的布局问题,尤其当使用浮动的时候,然而学习了BFC之后,其中的一些怪异现象,也因此成为理所当然,会有一种拨开云雾的快感. 下面简单介绍下BFC,究竟什么是BFC ...

  8. C++连接Oracle之OCCI(windows)

    上一节我们讲过了ADO连接Oracle,这一节我们尝试通过OCCI的方式,来在windows平台下连接Oracle数据库,下一节讨论在Linux环境下通过OCCI的方式连接远程的Oracle数据库. ...

  9. (转)游戏引擎中三大及时光照渲染方法介绍(以unity3d为例)

    重要:在目前市面上常见的游戏引擎中,主要采用以下三种灯光实现方式: 顶点照明渲染路径细节 Vertex Lit Rendering Path Details 正向渲染路径细节 Forward Rend ...

  10. 吴裕雄 实战python编程(1)

    import sqlite3 conn = sqlite3.connect('E:\\test.sqlite') # 建立数据库联接cursor = conn.cursor() # 建立 cursor ...