DesignPattern/04.BuilderPattern/2.Code/main.cpp

31 lines
538 B
C++
Raw Normal View History

2019-10-19 07:52:26 +00:00
#include "BuilderPattern.h"
int main()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AbstractBuilder *builder;
//ָ<><D6B8><EFBFBD><EFBFBD>
Director *director = new Director();
//<2F><>Ʒ<EFBFBD><C6B7>House
House *house;
//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BDA8><EFBFBD><EFBFBD>A
builder = new ConcreteBuilderA();
director->setBuilder(builder);
house = director->construct();
house->printfHouseInfo();
2020-11-29 07:28:46 +00:00
delete builder;
2019-10-19 07:52:26 +00:00
//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BDA8><EFBFBD><EFBFBD>B
builder = new ConcreteBuilderB();
director->setBuilder(builder);
house = director->construct();
house->printfHouseInfo();
system("pause");
2020-11-29 07:28:46 +00:00
delete director;
delete builder;
2019-10-19 07:52:26 +00:00
return 0;
}