zoukankan      html  css  js  c++  java
  • 23种设计模式之外观模式

    外观模式(Facade):为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。

     

    package designMode.facade;
    
    class SubSystemOne {
        public void methodOne(){
            System.out.println("子系统方法一");
        }
    }
    class SubSystemTwo {
        public void methodTwo(){
            System.out.println("子系统方法二");
        }
    }
    class SubSystemThree {
        public void methodThree(){
            System.out.println("子系统方法三");
        }
    }
    class SubSystemFour {
        public void methodFour(){
            System.out.println("子系统方法四");
        }
    }
    package designMode.facade;
    
    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("方法组A...");
            one.methodOne();
            two.methodTwo();
            four.methodFour();
        }
        
        public void methodB(){
            System.out.println("方法组B...");
            two.methodTwo();
            three.methodThree();
        }
    }
    package designMode.facade;
    
    class Test {
        public static void main(String[] args) {
            Facade facade = new Facade();
            
            facade.methodA();
            facade.methodB();
        }
    }
  • 相关阅读:
    前端-html/css
    数据结构-python
    接口测试-并发处理
    接口测试-高级运用
    接口测试-模拟网络请求
    接口测试-基础
    Jenkins-基础
    appium安装及环境搭建、入门
    Week12-unittest单元测试
    Redis在windows下安装与配置
  • 原文地址:https://www.cnblogs.com/lxcmyf/p/7404215.html
Copyright © 2011-2022 走看看