public class PersonDirector {
public Person constructPerson(PersonBuilder pb) {
pb.buildHead;
pb.buildBody;
pb.buildFoot;
return pb.buildPerson;
}
}
测试类:
package com.mode.create;
public class Test {
public static void main(String[] args) {
PersonDirector pd = new PersonDirector;
Person person = pd.constructPerson(new ManBuilder);
System.out.println(person.getBody);
System.out.println(person.getFoot);
System.out.println(person.getHead);
}
}
运行结果: