2016-12-11|887阅|作者:小楼昨夜又东风|举报 摘要:package prj00;
public class Role
{
private String sex;
private String face;
private String clothing;
private String hairstyle;
public void s
package prj00;
public class Role
{
private String sex;
private String face;
private String clothing;
private String hairstyle;
public void setSex(String sex){
this.sex= sex;
}
public void setFace(String face){
this.face= face;
}
public void setClothing(String clothing){
this.clothing= clothing;
}
public void setHairstyle(String hairstyle){
this.clothing= clothing;
}
public String getSex(){
return (this.sex);
}
public String getFace(){
return (this.face);
}
public String getClothing(){
return (this.clothing);
}
public String getHairstyle(){
return (this.hairstyle);
}
}
abstract class RoleBuilder
{
protected Role role = new Role();
public abstract void buildSex();
public abstract void buildFace();
public abstract void buildClothing();
public abstract void buildHairstyle();
public Role getRole()
{
return role;
}
}
class SubRoleBuilderA extends RoleBuilder{
public void buildSex() {
role.setSex("男");
}
public void buildFace() {
role.setFace("蛇精脸");
}
public void buildClothing() {
role.setClothing("魔法斗篷");
}
public void builderHairstyle() {
role.setHairstyle("卷发");
}
@Override
public void buildHairstyle() {
// TODO Auto-generated method stub
}
}
class SubRoleBuilderB extends RoleBuilder{
public void buildSex() {
role.setSex("女");
}
public void buildFace() {
role.setFace("妲己脸");
}
public void buildClothing() {
role.setClothing("隐形铠甲");
}
public void builderHairstyle() {
role.setHairstyle("长发飘飘");
}
@Override
public void buildHairstyle() {
// TODO Auto-generated method stub
}
}
class Director
{
private RoleBuilder ljq;
public void setRoleBuilder(RoleBuilder ljq)
{
this.ljq = ljq;
}
public Role construct()
{
ljq.buildSex();
ljq.buildFace();
ljq.buildClothing();
ljq.buildHairstyle();
return ljq.getRole();
}
}