package model.facade; /* *电力营销业务接口 */ public interface IElectricPowerMarketing { //代办用电变更 public String electricityChange(); //用电报修 public String electricityBuild(); //用电增容 public String electricityAmplitude(); //付费 public String pay(); } package model.facade; /* * 电力营销业务的实现类 */ public class IElectricPowerMarketingImpl implements IElectricPowerMarketing{ //用电增容 public String electricityAmplitude() { String a = "代办用电增容..."; System.out.println(a); return a; } //用电报修 public String electricityBuild() { String a = "代办用电报修..."; System.out.println(a); return a; } //用电变更 public String electricityChange() { String a = "代办用电变更..."; System.out.println(a); return a; } //代办用点付费 public String pay() { String a = "代办用电付费..."; System.out.println(a); return a; } } package model.facade; /* * 代办人类 */ public class PublicAgent { private IElectricPowerMarketing electricPowerMarketing = new IElectricPowerMarketingImpl(); //上门服务人员,为孤寡残疾老人提供办理、用电保修、用电增容用电变更、付费业务一体化服务 public String sendElectricity(){ return electricPowerMarketing.electricityChange() +electricPowerMarketing.electricityBuild() +electricPowerMarketing.electricityAmplitude() +electricPowerMarketing.pay(); } } package model.facade; /* * 客户端程序 */ public class Client { public static void main(String[] args) { //上门服务代理人 PublicAgent agent = new PublicAgent(); agent.sendElectricity(); } }
原文地址:http://blog.csdn.net/qqmaye/article/details/44016739