zoukankan      html  css  js  c++  java
  • 设计模式 配置器

    DesignPattern - Adapter

    已经有的存在的类,可能是别人写的,反正就是我们现在想拿来用的类SpecialOutput
    public class SpecialOutput
    {
        
    public void PrintSquare()
        
    {
            
    for(Int32 i=0; i<4; i++)
                Console.WriteLine(
    "* * * *");
        }


        
    public void PrintUnderline()
        
    {
            Console.WriteLine(
    "_______");
        }

    }
    我们自己的类Output想使用它的功能
    public class Output
    {
        
    private static SpecialOutput so= new SpecialOutput();
        
        
    public void PrintSquare()
        
    {
            so.PrintSquare();
        }


        
    public void PrintUnders()
        
    {
            so.PrintUnderline();
        }

    }
    测试程序
    public class App
    {
        
    public static void Main()
        
    {
            Output o 
    = new Output();
            o.PrintSquare();
            o.PrintUnders();
            Console.ReadLine();
        }

    }
    Adapter Demo
  • 相关阅读:
    codeforces689A
    codeforces222A
    codeforces553A
    2021牛客国庆集训派对day6 J
    SVM--支持向量机
    压缩感知
    范数
    LeNet详解
    卷积神经网络(CNN)详解
    BP算法实例—鸢尾花的分类(Python)
  • 原文地址:https://www.cnblogs.com/Dabay/p/365142.html
Copyright © 2011-2022 走看看