外观模式

@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css); 接口类:

package com.jerry.design.facade.imp;


public interface FacadeImp {

public void test();

public void testA();

public void testB();

public void testC();


}


实现类A:

package com.jerry.design.facade.impl;


import com.jerry.design.facade.imp.FacadeImp;



public class TestA implements FacadeImp {

public void test(){

System.out.println(" i am TestA's test()!");

}


@Override

public void testA() {

System.out.println(" i am TestA's testA()!");

}


@Override

public void testB() {

}


@Override

public void testC() {

}


}


实现类B:

package com.jerry.design.facade.impl;


import com.jerry.design.facade.imp.FacadeImp;



public class TestB implements FacadeImp {

public void test(){

System.out.println(" i am TestB's test()!");

}


@Override

public void testA() {

}


@Override

public void testB() {

System.out.println(" i am TestB's testB()!");

}


@Override

public void testC() {

}


}


实现类C:

package com.jerry.design.facade.impl;


import com.jerry.design.facade.imp.FacadeImp;



public class TestC implements FacadeImp {

public void test(){

System.out.println(" i am TestC's test()!");

}


@Override

public void testA() {

}


@Override

public void testB() {

}


@Override

public void testC() {

System.out.println(" i am TestC's testC()!");

}


}


外观类:

package com.jerry.design.facade.impl;


public class Facade {

public void testFacadeImplA(){

new TestA().test();

new TestB().test();

new TestC().test();

}

   public void testFacadeImplB(){

new TestA().testA();

new TestB().testB();

new TestC().testC();

}


}


调用代码:

package com.jerry.design.facade.client;


import com.jerry.design.facade.impl.Facade;


public class Test {


/**

* @param args

*/

public static void main(String[] args) {


new Facade().testFacadeImplA();

// i am TestA's test()!

// i am TestB's test()!

// i am TestC's test()!

new Facade().testFacadeImplB();

// i am TestA's testA()!

// i am TestB's testB()!

// i am TestC's testC()!

}


}

 

 


总结:使子系统易用

 

 

 

posted on 2012-02-15 20:54 疯狂的蜗牛 阅读(58) 评论(0)  编辑  收藏 所属分类: 设计模式


只有注册用户登录后才能发表评论。


网站导航:
 
<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

导航

统计

公告

@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);

常用链接

留言簿

随笔档案

文章分类

文章档案

搜索

最新评论