zoukankan      html  css  js  c++  java
  • 外观模式

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

    子系统

        class SubSystemOne
        {
            public void MethodOne()
            {
                Console.WriteLine("方法一");
            }
        }
    
        class SubSystemTwo
        {
            public void MethodTwo()
            {
                Console.WriteLine("方法二");
            }
        }
    
        class SubSystemThree
        {
            public void MethodThree()
            {
                Console.WriteLine("方法三");
            }
        }

    外观类

        class Facade
        {
            SubSystemOne one;
            SubSystemTwo two;
            SubSystemThree three;
    
            public Facade()
            {
                one = new SubSystemOne();
                two = new SubSystemTwo();
                three = new SubSystemThree();
            }
    
            public void MethodA()
            {
                one.MethodOne();
                two.MethodTwo();
            }
    
            public void MethodB()
            {
                three.MethodThree();
            }
        }

    客户端代码

            static void Main(string[] args)
            {
                Facade facade = new Facade();
    
                facade.MethodA();
                facade.MethodB();
    
                Console.ReadKey();
            }
  • 相关阅读:
    jdbc入门
    mysql 各项操作流程
    python中的细小知识点罗列
    Linux之高级指令
    linux之进阶指令
    Linux之基础指令
    STL之适配器
    STL之谓词
    STL之函数对象
    STL之map容器和multimap容器
  • 原文地址:https://www.cnblogs.com/baiqjh/p/2843914.html
Copyright © 2011-2022 走看看