• 我的设计模型之适配器模式


    今天上午项目基本结束了 所以有时间学习一下设计模式了 在网上搜素了一下 好多关于这方面的文章 自己也是按照吕震宇大哥的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 类的行为啊,期待高手解答啊
  • 相关阅读:
    Proximal Gradient Descent for L1 Regularization
    使用Spring Security3的四种方法概述
    理解spring对事务的处理:传播性
    MySQL事务隔离级别详解
    Spring 使用注解方式进行事务管理
    Redis的高级应用-安全性和主从复制
    Redis的高级应用-事务处理、持久化、发布与订阅消息、虚拟内存使用
    mysql 语句优化心得
    Maven搭建Spring Security3.2项目详解
    Java网络编程之TCP、UDP
  • 原文地址:https://www.cnblogs.com/DrEdison/p/1232918.html
Copyright © 2020-2023  润新知