int main( int argc, char* argv[] ) { Builder* b = new ConcreteBuilder(); Director* d = new Director(b); d->Construct(); b->GetProduct(); return 0; }
int main(int argc, char *argv[]) { Director* pDirector = new Director(new ConcreteBuilder1()); pDirector->Construct(); Director* pDirector1 = new Director(new ConcreteBuilder2()); pDirector1->Construct(); return 0; }
int main(int argc, char* argv[]) { Product* pro;//接收产品的指针 //将一个具体的构建者付给指挥者 Director* d = new Director(new ConcreteBuilder()); pro=d->Construct();//调用产生产品 pro->fun(); printf("Hello World!\n"); return 0; }
//builder.h int main1() { Director* pDirector = new Director(new ConcreteBuilder1()); pDirector->Construct(); Director* pDirector1 = new Director(new ConcreteBuilder2()); pDirector1->Construct(); return 0; }
void test_builder() { Builder* bld = new ConcreteBuilder; Director* dct = new Director(bld); dct->Construct(); ProductBuild* pdt = bld->GetProduct(); pdt->Show(); delete bld; delete dct; }
int main() { Director d; //GoF ���Ͽ��� ������ Korea k; Spain s; // ������.. �� �����!! d.setBuilder(&s); //����ڰ� ij���� ���� ȭ��ǥ Ű�� // ������... Character c = d.Construct(); cout << c << endl; }
int main() { Director* director = new Director(); Builder* b1 = new ConcreteBuilder1(); Builder* b2 = new ConcreteBuilder2(); director->Construct(b1); Product* p1 = b1->GetResult(); p1->Show(); std::cin.get(); return 0; }
int main(int argc, char *argv[]) { Product* product = new Product(); Build *build = new ConcreteBuild(product); Director *directot = new Director(build); directot->Construct(); vector<string>::iterator ite; for(ite = product->vec.begin();ite != product->vec.end(); ++ite) { cout << *ite << endl; } return 0; }
int main() { // Create director and builders Director* lpDirector = new Director; Builder* lpBuilder1 = new ConcreteBuilder1; Builder* lpBuilder2 = new ConcreteBuilder2; // Construct two products lpDirector->Construct(lpBuilder1); Product* lpProduct1 = lpBuilder1->GetResult(); lpProduct1->Show(); lpDirector->Construct(lpBuilder2); Product* lpProduct2 = lpBuilder2->GetResult(); lpProduct2->Show(); // Wait for user int input; cin >> input; return 0; }
int main(int argc,char* argv[]) { QApplication app(argc,argv); factoryModel style = EPAbstractFactory; if (style == EPEffective) { Shape *pr = new Rectangle; pr->draw(); pr->draw(Shape::Green); Shape *pc = new Circle; pc->draw(Shape::Blue); } else if (style == EPFactory) { Factory *fac = new ConcreteFactory(); Product *p = fac->CreateProduct(); delete p; } else if (style == EPBuilder ) { Director* d = new Director(new ConcreteBuilder()); d->Construct(); } else if (style == EPAbstractFactory) { AbstractFactory *cf1 = new ConcreteFactory1(); cf1->CreateProductA(); cf1->CreateProductB(); AbstractFactory *cf2 = new ConcreteFactory2(); cf2->CreateProductA(); cf2->CreateProductB(); int *p = NULL; int x = 10; p = &x; ConcreteFactory2 *cf3 = (ConcreteFactory2*)cf2; cf3->create(p); } return app.exec(); }
///当我们要创建的对象很复杂的时候(通常是 由很多其他的对象组合而成),我们要要复杂对象的创建过程和这个对象的表示(展示)分 离开来,这样做的好处就是通过一步步的进行复杂对象的构建,由于在每一步的构造过程中 可以引入参数,使得经过相同的步骤创建最后得到的对象的展示不一样 ///Builder 建造者模式和 AbstractFactory 模式在功能上很相似,因为都是用来创建大的复杂的对 象,它们的区别是:Builder 模式强调的是一步步创建对象,并通过相同的创建过程可以获 得不同的结果对象,一般来说 Builder 模式中对象不是直接返回的。而在 AbstractFactory 模 式中对象是直接返回的,AbstractFactory 模式强调的是为创建多个相互依赖的对象提供一个 同一的接口。 void BuilderTest() { Director* d = new Director(new ConcreteBuilder()); d->Construct(); }
int main(int argc,char* argv[]) { Director* d = new Director(new ConcreteBuilder()); d->Construct(); return 0; }