当前位置:首页 > 设计模式 > 正文内容

外观模式

canca19年前 (2007-03-26)设计模式485

//外观模式
//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();
 }
}

扫描二维码推送至手机访问。

版权声明:本文由Ant.Master's Blog发布,如需转载请注明出处。

本文链接:https://iant.work/post/661.html

标签: 设计模式
分享给朋友:
返回列表

上一篇:适配器模式

下一篇:享元模式

“外观模式” 的相关文章

抽象工厂模式

//抽象工厂模式//Copyright CAnca Software office//Created by CAnca.2006public class AbstractFactory{ public static void main(String[] args){  ...

单例模式

//CopyRight CAnca Software Office. 2006//Created by CAnca. import java.util.*; public class singletonMode{ public static void main(String[] args)...

建造者模式

//建造者模式//CopyRight(C)CAnca Software Office.//Created by CAnca. import java.util.*; public class BuilderMode{ public static void main(String[] arg...

原型模式

//原型模式//CopyRight(C) CAnca Software Office.2006//Created by CAnca. public class PrototypeMode{ public static void main(String[] args){  ...

代理模式

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

桥接模式

//桥接模式//CopyRight(C) CAnca Software Office 2006.//Created by CAnca. import java.util.*; public class BridgeMode{ public static void main(String[]...

发表评论

访客

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