2016-12-11|794阅|作者:小楼昨夜又东风|举报 摘要: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();
}
}