1类图
2c++实现
; { : string getBody() { body; } setBody( string body) { body body; } string getHead() { head; } setHead( string head) { head head; } string getTail() { tail; } setTail( string tail) { tail tail; } : string head; string body; string tail; }; { : buildHead(); buildBody(); buildTail(); Car getResult(); ~Builder(){} }; : Builder{ : CarBuilder(Car car){ carcar; } : buildHead(){ carsetHead(); } buildBody(){ carsetBody(); } buildTail(){ carsetTail(); } Car getResult(){ car; } : Car car; }; { : Director(Builder builder){ builderbuilder; } : build(){ builderbuildHead(); builderbuildBody(); builderbuildTail(); } : Builder builder; }; (){ Car car Car; Builder builder CarBuilder(car); Director director Director(builder); directorbuild(); carbuildergetResult(); coutcargetHead()endl; coutcargetBody()endl; coutcargetTail()endl; ; }