用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

小楼昨夜又东风    -  云代码空间

——

设计模式

2016-12-11|798阅||

摘要:public void setCpu(String cpu){ this.cpu = cpu; } public void setMemory(String memory){ this.memory = memory; } public void setDisk(String d



public void setCpu(String cpu){
this.cpu = cpu;
}
public void setMemory(String memory){
this.memory = memory;
}
public void setDisk(String disk){
this.disk = disk;
}
public void setHost(String host){
this.host = host;
}
public void Monitor(String monitor){
this.monitor =monitor;
}

public String getCpu(){
return (this.cpu);
}

public String getMemory(){
return (this.memory);
}

public String getDisk(){
return (this.disk);
}

public String getHost(){
return (this.host);
}

public String getMonitor(){
return (this.monitor);
}

}
abstract class ComputerBuilder {
protected computer computer = new computer();


public abstract void buildCpu();


public abstract void buildMemory();


public abstract void builderDisk();


public abstract void buildHost();


public abstract void buildMonitor();


public computer getComputer() {
return computer;
}
}


 abstract class Laptop extends ComputerBuilder {


public void buildCpu() {
computer.setCpu("酷睿");
}


public void buildMemory() {
computer.setMemory("金士顿");
}


public void buildDisk() {
computer.setDisk("希捷");
}


public void buildHost() {
computer.setHost("没有");
}


public void buildMonitor() {
computer.Monitor("神舟");
}
}


 abstract class Desktop extends ComputerBuilder {


public void buildCpu() {
computer.setCpu("酷睿");
}


public void buildMemory() {
computer.setMemory("金士顿");
}


public void buildDisk() {
computer.setDisk("希捷");
}


public void buildHost() {
computer.setHost("主机");
}


public void buildMonitor() {
computer.Monitor("LG");
}
}


 abstract class ServerHost extends ComputerBuilder {


public void buildCpu() {
computer.setCpu("酷睿");
}


public void buildMemory() {
computer.setMemory("金士顿");
}


public void buildDisk() {
computer.setDisk("希捷");
}


public void buildHost() {
computer.setHost("主机");
}


public void buildMonitor() {
computer.Monitor("无");
}
}


class Director2{
private ComputerBuilder jq;


public void setComputerBuilder(ComputerBuilder jq) {
this.jq = jq;
}

public computer construct(){
jq.buildCpu();
jq.buildMemory();
jq.builderDisk();
jq.buildHost();
jq.buildMonitor();
return jq.getComputer();

}

}


顶 0踩 0收藏
文章评论
    发表评论

    个人资料

    • 昵称: 小楼昨夜又东风
    • 等级: 中级程序员
    • 积分: 50
    • 代码: 0 个
    • 文章: 5 篇
    • 随想: 0 条
    • 访问: 0 次
    • 关注

    人气文章

    人气代码

      标签

      站长推荐