当前位置: 首页 > news >正文

网站开发 卓优科技做网站购买什么软件

网站开发 卓优科技,做网站购买什么软件,公司网站发展规划书,北京专业网页制作公司文章目录 一、定义抽象产品接口二、定义抽象工厂接口三、定义具体产品四、定义具体工厂五、定义工厂客户端六、客户端调用工厂客户端七、抽象工厂模式的结构 一、定义抽象产品接口 //------------------------------------------------------------------ //| participants … 文章目录 一、定义抽象产品接口二、定义抽象工厂接口三、定义具体产品四、定义具体工厂五、定义工厂客户端六、客户端调用工厂客户端七、抽象工厂模式的结构 一、定义抽象产品接口 //------------------------------------------------------------------ //| participants | //------------------------------------------------------------------ // abstract product declares an interface for a type of products //------------------------------------------------------------------ //| participants abstract product | //------------------------------------------------------------------ interface AbstractProductA{}; //------------------------------------------------------------------ //| participants abstract product | //------------------------------------------------------------------ interface AbstractProductB{void Interact(AbstractProductA*);}; 二、定义抽象工厂接口 //------------------------------------------------------------------ //| participants | //------------------------------------------------------------------ interface AbstractFactory // declares an interface for operations that create abstract products {AbstractProductA* CreateProductA(void);AbstractProductB* CreateProductB(void); }; 三、定义具体产品 //------------------------------------------------------------------ //| participants | //------------------------------------------------------------------ // concrete product // defines product object to be created by concrete factory // implements abstract product interface //------------------------------------------------------------------ //| participants concrete product | //------------------------------------------------------------------ class ProductA1:public AbstractProductA {public:ProductA1(void); }; void ProductA1::ProductA1(void) {Print(product a1 constructed);} //------------------------------------------------------------------ //| participants concrete product | //------------------------------------------------------------------ class ProductA2:public AbstractProductA {public:ProductA2(void); }; void ProductA2::ProductA2(void) {Print(product a2 constructed);} //------------------------------------------------------------------ //| participants concrete product | //------------------------------------------------------------------ class ProductB1:public AbstractProductB {public:ProductB1(void);void Interact(AbstractProductA*); }; void ProductB1::ProductB1(void) {Print(product b1 constructed);} void ProductB1::Interact(AbstractProductA*src) {Print(product b1: ,this, is interacting with product a: ,src); } //------------------------------------------------------------------ //| participants concrete product | //------------------------------------------------------------------ class ProductB2:public AbstractProductB {public:ProductB2(void);void Interact(AbstractProductA*); }; void ProductB2::ProductB2(void) {Print(product b2 constructed);} void ProductB2::Interact(AbstractProductA*src) {Print(product b2: ,this, is interacting with product a: ,src); } // // 四、定义具体工厂 //------------------------------------------------------------------ //| participants | //------------------------------------------------------------------ // concrete factory implements operations create concrete products //------------------------------------------------------------------ //| participants concrete factory | //------------------------------------------------------------------ class Factory1:public AbstractFactory {public:Factory1(void);AbstractProductA* CreateProductA(void);AbstractProductB* CreateProductB(void); }; //------------------------------------------------------------------ //| participants concrete factory factory 1 | //------------------------------------------------------------------ void Factory1::Factory1(void) {Print(factory 1: ,this, constructed); } //------------------------------------------------------------------ //| participants concrete factory factory 1 | //------------------------------------------------------------------ AbstractProductA* Factory1::CreateProductA(void) {printf(factory 1 is creating and returning product a1);return new ProductA1; } //------------------------------------------------------------------ //| participants concrete factory factory 1 | //------------------------------------------------------------------ AbstractProductB* Factory1::CreateProductB(void) {printf(factory 1 is creating and returning product b1);return new ProductB1; } //------------------------------------------------------------------ //| participants concrete factory | //------------------------------------------------------------------ class Factory2:public AbstractFactory {public:Factory2(void);AbstractProductA* CreateProductA(void);AbstractProductB* CreateProductB(void); }; //------------------------------------------------------------------ //| participants concrete factory factory 2 | //------------------------------------------------------------------ void Factory2::Factory2(void) {Print(factory 2: ,this, constructed); } //------------------------------------------------------------------ //| participants concrete factory factory 2 | //------------------------------------------------------------------ AbstractProductA* Factory2::CreateProductA(void) {printf(factory 2 is creating and returning product a2);return new ProductA2; } //------------------------------------------------------------------ //| participants concrete factory factory 2 | //------------------------------------------------------------------ AbstractProductB* Factory2::CreateProductB(void) {printf(factory 2 is creating and returning product b2);return new ProductB2; }五、定义工厂客户端 //------------------------------------------------------------------ //| participants | //------------------------------------------------------------------ class FactoryClient // uses interfaces declared by abstract factory, abstract product {public:void Run(void);void Switch(AbstractFactory*);FactoryClient(AbstractFactory*);~FactoryClient(void);protected:AbstractProductA* apa;AbstractProductB* apb;AbstractFactory* factory;void Delete(void); }; //------------------------------------------------------------------ //| participants factory client | //------------------------------------------------------------------ void FactoryClient::FactoryClient(AbstractFactory* af) {Print(factory client created and received abstract factory ,af);Print(factory client is requesting to accept/switch the factories);Switch(af); } //------------------------------------------------------------------ //| participants factory client | //------------------------------------------------------------------ void FactoryClient::~FactoryClient(void) {Delete(); } //------------------------------------------------------------------ //| participants factory client | //------------------------------------------------------------------ void FactoryClient::Run(void) {Print(factory client is running abstract product b);apb.Interact(apa); } //------------------------------------------------------------------ //| participants factory client | //------------------------------------------------------------------ void FactoryClient::Delete(void) {delete apa;delete apb;delete factory; } //------------------------------------------------------------------ //| participants factory client | //------------------------------------------------------------------ void FactoryClient::Switch(AbstractFactory *af) {string sFactory;StringConcatenate(sFactory,sFactory,factory);int iFactory(int)StringToInteger(sFactory);if(iFactory0){Print(factory client is switching old factory ,factory, to new factory ,af);}else{Print(factory client is accepting new factory ,af);}Delete();factoryaf;Print(factory client saved the new factory);Print(factory client is requesting its new factory to create product a);apafactory.CreateProductA();Print(factory client is requesting its new factory to create product b);apbfactory.CreateProductB(); } 六、客户端调用工厂客户端 //------------------------------------------------------------------ //| interface for patterns | //------------------------------------------------------------------ interface ClientExample //pattern client {string Output(void); //returns headervoid Run(void); //execute the pattern client };//------------------------------------------------------------------ //| participants | //------------------------------------------------------------------ class Client:public ClientExample{ public:string Output(void);void Run(void);}; string Client::Output(void) {return __FUNCTION__;} //------------------------------------------------------------------ //| collaborations | //------------------------------------------------------------------ void Client::Run(void) // concrete factory // a single instance normally created at run-time // creates products with particular implementation // client uses other factory for different product objects // abstract factory // defers creation product objects concrete factory subclass{Print(client is requesting to create factory 1);Print(client is requesting to create the factory client);Print(client is requesting the factory client to manage factory 1);FactoryClient client(new Factory1);Print(client is requesting the factory client to operate);client.Run();Print(client is requesting to create new factory 2 and asking factory client to switch factories);client.Switch(new Factory2);Print(client is requesting the factory client to run again);client.Run();} } 七、抽象工厂模式的结构 //------------------------------------------------------------------ //| structure | //------------------------------------------------------------------ // // | AbstractFactory|-----------------------------------------|Client| // |----------------| | // |CreateProductA()| | // |CreateProductA()| |AbstractProductA|------- // ^ ^ | // | | | // --------------------- ---------- | // | | | | | //|ConcreteFactory1|- |ConcreteFactory2|- -|ProductA2| |ProductA1|- | //|----------------| | |----------------| | | | //|CreateProductA()| |CreateProductA()| | //|CreateProductB()| | |CreateProductB()| | | | // |AbstractProductB|------ // | | ^ | // | // | | ---------- | // | | // | -|ProductB2| |ProductB1|- // | // - - - - - - - - - - - - - - - - - - - - - - - - -
http://www.hyszgw.com/news/127999/

相关文章:

  • 网站制作排版如何搭建自己的网站
  • 网站建设明细价格表深圳企业网站公司
  • 建站行业怎么样做旅游网站的方法
  • 一键搭建网站windowscrm平台系统
  • 海尔网站建设的缺点网站里的动画效果图
  • 九江市做网站的公司活动策划流程及细节
  • 黄山网站建设哪家强嘉兴网站建设推荐浙江华企
  • 在网站上做封面泊头建网站
  • linux主机做网站做qq图片的网站
  • 湖北神润建设工程有限公司网站中国住房和城乡建设网官网
  • 苏宁易购网站建设建议推广产品的文案
  • 天津建设工程交易中心网站wordpress视频去广告
  • 迪庆企业网站建设公司热狗网站排名优化外包
  • word68网站响应式网站特点
  • 促销礼品网站建设网站浮动咨询代码
  • 注册域名查询网站网站美化怎么做
  • 自己用dw做网站能加声音吗设计ui属于什么专业
  • 没有有知道钓鱼网站在哪儿做哪家做网站公司好
  • 网站开发的重要性ppt链接网站怎么做
  • 影楼网站源码南通做网站多少钱
  • 昆明优化官网服务seo sem 外贸建站 网站建设 文化墙设计
  • 适合网站开发的框架台州网约车最新政策
  • 做电影网站为什么要数据库怎么网站定制
  • 沛县做网站网络营销外包网
  • 原阳网站建设长尾词挖掘工具
  • 福田网站建设方案费用集团官网建设公司
  • 建网站软件哪个好电商网站公司
  • 外包网站会自己做原型吗滨州网站建设九鲁
  • 最新的网站建设软件网站管理系统哪个最好
  • wp系统网站如何做seo怎么利用花生壳做自己的网站