#include "Builder.h" #include "spdlog.h" void buildSunnyShip() { ShipFactory* factory = new ShipFactory(); SunnyShipBuilder* builder = new SunnyShipBuilder(); factory->setBuilder(builder); /* 创建简约型 */ factory->builderSimpleShip(); SunnyShip* ship = builder->getShip(); SPDLOG_INFO("Sunny简约型:"); ship->ShowParts(); delete ship; /* 创建标准型 */ builder->reset(); factory->builderStandardShip(); ship = builder->getShip(); SPDLOG_INFO("Sunny标准型:"); ship->ShowParts(); delete ship; /* 创建豪华型 */ builder->reset(); factory->builderRegalShip(); ship = builder->getShip(); SPDLOG_INFO("Sunny豪华型:"); ship->ShowParts(); delete ship; } /* 创建Merry号 */ void buildMerryShip() { ShipFactory* factory = new ShipFactory(); MerryShipBuilder* builder = new MerryShipBuilder(); factory->setBuilder(builder); /* 创建简约型 */ factory->builderSimpleShip(); MerryShip* ship = builder->getShip(); SPDLOG_INFO("Merry简约型:"); ship->ShowParts(); delete ship; /* 创建标准型 */ builder->reset(); factory->builderStandardShip(); ship = builder->getShip(); SPDLOG_INFO("Merry标准型:"); ship->ShowParts(); delete ship; /* 创建豪华型 */ builder->reset(); factory->builderRegalShip(); ship = builder->getShip(); SPDLOG_INFO("Merry豪华型:"); ship->ShowParts(); delete ship; }