zoukankan      html  css  js  c++  java
  • 炒粉还是煮面

    儿子: 爸爸,今天早餐吃什么?是炒粉还是煮面?
    爸爸: 你想吃哪种呢?
    儿子: 我想吃煮面。
    爸爸: 煮面也有很多种,你想吃鸡蛋煮面,虾煮面,肉片煮面......

    儿子: 我选虾煮面。


     

    从开发角度来说,不管是还是,它是只是一个动作或方法。因此可以定义成为两个接口:

    ICookable
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for ICookable
    /// </summary>
    namespace Insus.NET
    {
        public interface ICookable
        {
            void Cook();
        }
    }
    ISauteable
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for ISauteable
    /// </summary>
    namespace Insus.NET
    {
        public interface ISauteable
        {
            void Saute();
        }
    }

    接下来,Insus.NET实现儿子的早餐:

    View Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Insus.NET;

    public partial class Breakfast : System.Web.UI.Page, ICookable
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void Cook()
        {
            //主材料:虾,面,生菜叶;
            
    //辅料:花生油,盐,酱油...
            Response.Write("虾煮面做好了。");
        }
    }
  • 相关阅读:
    scapy学习笔记(4)简单的sniffing 嗅探
    scapy学习笔记(3)发送包,SYN及TCP traceroute 扫描
    Linux查看CPU和内存使用情况
    MySQL关于根据日期查询数据的sql语句
    JSON 数据格式
    利用PyCharm进行Python远程调试
    pycharm远程调试配置
    Linux终端使用技巧
    每天一个linux命令(60):scp命令
    python-docx 使用教程
  • 原文地址:https://www.cnblogs.com/insus/p/2278723.html
Copyright © 2011-2022 走看看