外观模式

canca17年前 (2007-03-26)设计模式296

//外观模式
//CopyRight(C)CAnca Software Office. 2006
//Created by CAnca.

public class FacadeMode{
 public static void main(String[] args){
  Facade f = new Facade();
  f.MethodA();
  f.MethodB();
 }
}

//subSystem A
class FacadeA{
 public void MethodA(){
  System.out.println("This is the first Facade method.");
 }
}
//subSystem B
class FacadeB{
 public void MethodB(){
  System.out.println("This is the second Facade method.");
 }
}
//subSystem C
class FacadeC{
 public void MethodC(){
  System.out.println("This is the third Facade method.");
 }
}
//subSystem D
class FacadeD{
 public void MethodD(){
  System.out.println("This is the fourth Facade method.");
 }
}

class Facade{
 private FacadeA fa;
 private FacadeB fb;
 private FacadeC fc;
 private FacadeD fd;
 public Facade(){
  fa = new FacadeA();
  fb = new FacadeB();
  fc = new FacadeC();
  fd = new FacadeD();
 }
 public void MethodA(){
  fa.MethodA();
  fb.MethodB();
  fc.MethodC();
 }
 
 public void MethodB(){
  fa.MethodA();
  fd.MethodD();
 }
}

相关文章

抽象工厂模式

//抽象工厂模式//Copyright CAnca Software office//Created by CAnca.2006public class AbstractFactory{ p...

工厂方法模式

//工厂方法模式:现实例子//CopyRight(C)CAnca Software Office. 2006//Created by CAnca. import java.util.*; public...

原型模式

//原型模式//CopyRight(C) CAnca Software Office.2006//Created by CAnca. public class PrototypeMode{ ...

代理模式

//代理模式--真实例子//CopyRight(C)CAnca Software Office.2006//Created by CAnca.   public class ProxyMod...

桥接模式

//桥接模式//CopyRight(C) CAnca Software Office 2006.//Created by CAnca. import java.util.*; public class...

适配器模式

//适配器模式//CopyRight(C)CAnca Software Office.//Created by CAnca. public class AdapterMode{ public...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。