zoukankan      html  css  js  c++  java
  • 我的设计模型之适配器模式

    今天上午项目基本结束了 所以有时间学习一下设计模式了 在网上搜素了一下 好多关于这方面的文章 自己也是按照吕震宇大哥的Demo 写了一遍 力求理解 放代码
     1using System;
     2using System.Collections.Generic;
     3using System.Linq;
     4using System.Text;
     5
     6namespace 泡妞的故事
     7{
     8    class Program
     9    {
    10        static void Main(string[] args)
    11        {
    12            Agreement ag = new Agreement();
    13            Console.WriteLine("纪晓岚:老夫人,我们去读书了!");
    14            Console.WriteLine("老夫人:乖,好好读呀!");
    15            ag.Reading();
    16            Console.WriteLine("纪晓岚:老夫人,我们去练字了!");
    17            Console.WriteLine("老夫人:好呀好呀!");
    18            ag.Writing();
    19        }

    20    }

    21    class Girl
    22    
    23      public void  Eating()
    24      {
    25          Console.WriteLine("和姑娘吃东西啊");
    26          Console.ReadLine();
    27      }

    28      public void Shopping()
    29      {
    30          Console.WriteLine("和姑娘吃购物啊");
    31          Console.ReadLine();
    32      }

    33      public void Travelling()
    34      {
    35          Console.WriteLine("和姑娘吃游山玩水啊");
    36          Console.ReadLine();
    37      }

    38    }

    39    public interface Mother
    40    {
    41        void Reading();
    42        void Writing();
    43    }

    44    public class Agreement : Mother
    45    {
    46        Girl girl = new Girl();
    47        public void Reading()
    48        {
    49            girl.Eating();
    50            girl.Shopping();
    51        }

    52        public void Writing()
    53        {
    54            girl.Travelling();
    55        }

    56    }

    57
    58}

    59
    不过最后我还是有一个问题 接口是用来做什么的呢 在这里 他并没有限制Agreement 类的行为啊,期待高手解答啊
  • 相关阅读:
    js页面问题--(ing)
    tomcat9以后对,请求消息头的严格字符要求
    linux常用命令--(不断更新)
    怎么用wireshark看抓包文件
    关于h2的启动问题
    VUE-02 基本指令
    RecyclerView设置空视图
    SpringBoot-JPA删除不成功,只执行了查询语句
    关于RecyclerView(二)设置EmptyView
    关于RecyclerView(一)基本使用
  • 原文地址:https://www.cnblogs.com/DrEdison/p/1232918.html
Copyright © 2011-2022 走看看