摘要: 1 /* 2 * 建造者模式是一种创建型模式,它主要是应对项目中一些复杂对象的创建工作。 3 * 所谓“复杂对象”,是指此对象中还含有其它的子对象。 4 * 我们现在定义一个场景:汽车生产必须包含车轮(Wheel)、油箱(OilBox)和车身(Body), 5 * 应用建造者模式,用C#控制台应用程序实现该设计,构建BMW品牌和BenZ品牌汽车生产。 6 */ 7 using System; 8 using System.Collections.Generic; 9 using System.Linq; 10 using System.Text; 11 12 n... 阅读全文
posted @ 2012-05-14 22:56 ZH奶酪 阅读(515) 评论(0) 推荐(0) 编辑
摘要: 麦当劳(McDonalds)和肯德基(KFC)快餐店都经营汉堡(Hamburg)和可乐(Cola),用C#控制台应用程序实现这两个快餐店经营产品的抽象工厂模式。 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace AbstractFactory 7 { 8 //汉堡接口 9 interface IHamburg10 {11 }12 //KFC汉堡13 class KFCHamburg... 阅读全文
posted @ 2012-05-14 21:55 ZH奶酪 阅读(667) 评论(0) 推荐(0) 编辑
摘要: 有一个OEM制造商代理做HP笔记本电脑(Laptop),后来该制造商得到了更多的品牌笔记本电脑的订单Acer,Lenovo,Dell,该OEM商发现,如果一次同时做很多个牌子的本本,有些不利于管理。利用工厂模式改善设计,用C#控制台应用程序实现该OEM制造商的工厂模式。 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace Factory 7 { 8 class Laptop 9 {10 }11 cl... 阅读全文
posted @ 2012-05-14 21:53 ZH奶酪 阅读(614) 评论(0) 推荐(0) 编辑
摘要: 很多应用项目都有配置文件,这些配置文件里面定义一些应用需要的参数数据。通常客户端使用这个类是通过new一个AppConfig的实例来得到一个操作配置文件内容的对象。如果在系统运行中,有很多地方都需要使用配置文件的内容,系统中会同时存在多份配置文件的内容,这会严重浪费内存资源。事实上,对于AppConfig类,在运行期间,只需要一个对象实例就够了。那么应该怎么实现呢?用C#控制台应用程序实现该单例模式。 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 . 阅读全文
posted @ 2012-05-14 21:52 ZH奶酪 阅读(757) 评论(0) 推荐(0) 编辑
摘要: Problem : 1862 ( EXCEL排序 ) Judge Status : AcceptedRunId : 5941834Language : C++Author : qq1203456195Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 struct e 5 { 6 char t[20],name[20]; 7 int s; 8 阅读全文
posted @ 2012-05-14 13:32 ZH奶酪 阅读(268) 评论(0) 推荐(0) 编辑