class SubSystemOne
{
public void MethodOne()
{
System.out.println(1);
}
}
class SubSystemTwo
{
public void MethodTwo()
{
System.out.println(2);
}
}
class SubSystemThree
{
public void MethodThree()
{
System.out.println(3);
}
}
class SubSystemFour
{
public void MethodFour()
{
System.out.println(4);
}
}
public class facade {
SubSystemOne one;
SubSystemTwo two;
SubSystemThree three;
SubSystemFour four;
public facade()
{
one = new SubSystemOne();
two = new SubSystemTwo();
three = new SubSystemThree();
four = new SubSystemFour();
}
public void MethodA()
{
System.out.println("1111111");
one.MethodOne();
two.MethodTwo();
four.MethodFour();
}
public void MethodB()
{
System.out.println("22222222222");
two.MethodTwo();
three.MethodThree();
four.MethodFour();
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
facade f = new facade();
f.MethodA();
f.MethodB();
}
}
外观模式
最新推荐文章于 2024-08-05 11:05:13 发布
本文介绍了一个使用Java实现的门面模式示例,通过创建一个Facade类来调用不同子系统的功能方法,展示了如何简化复杂的子系统接口,提供一个统一的高层接口供客户端使用。
176

被折叠的 条评论
为什么被折叠?



