3、c voidsetSex(Stringsex){ this.sex =sex; } public voidsetFace(Stringface){ this.face =face; } public voidsetCostume(Stringcostume){ this.costume =costume; } public voidsetHairstyle(Stringhairs
4、tyle){ this.hairstyle =hairstyle; } public StringgetType(){ return (this.type); } public StringgetSex(){ return (this.sex); } public StringgetFace(){ return (this.face); }
5、 public StringgetCostume(){ return (this.costume); } public StringgetHairstyle(){ return (this.hairstyle); }} //角色建造器:抽象建造者abstractclassActorBuilder{ protected Actoractor=newActor(); public abstractvo
6、idbuildType(); public abstractvoidbuildSex(); public abstractvoidbuildFace(); public abstractvoidbuildCostume(); public abstractvoidbuildHairstyle(); //工厂方法,返回一个完整的游戏角色对象 publicActorcreateActor() { returnactor;
7、 }} //英雄角色建造器:具体建造者classHeroBuilderextendsActorBuilder{ public voidbuildType() { actor.setType("英雄"); } public voidbuildSex() { actor.setSex("男"); } public voidbuildFace() { acto
8、r.setFace("英俊"); } public voidbuildCostume() { actor.setCostume("盔甲"); } public voidbuildHairstyle() { actor.setHairstyle("飘逸"); } } //天使角色