惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - tf.li

清理MVC4 Internaet 项目模板清理 SQL2014 尝试读取或写入受保护的内存。这通常指示其他内存已损坏 nodejs 环境配置技巧 mongdb window 服务安装批处理 bower 安装后 jade 引用404问题 我的Prototype模式框架 转自CnBeta 令人深思 [译稿]为什么我们不要 .NET 程序员 JSON.NET、WebService与JQuery协同工作 我修改的IP地址掩码 呵呵~~开心 Ext.Ajax.request 传值问题 从小做大之一---------一切从建模开始 [求助]关于文本行转列的疑问~~ To Terrylee 我的设计模型之小议工厂模式 我的设计模型之装饰者模式 我对线程池的一点理解 面向接口编程之惑 我的设计模型之适配器模式 我的设计模型之简单工厂
面向接口编程之惑 第二版
tf.li · 2008-07-20 · via 博客园 - tf.li

面向接口编程之惑 第二版

刚才对面向接口充满了疑惑 经过自己的仔细推敲 加上 Vs 的智能提示 终于找到解决方法了 放代码出来啊 如果你刚看过那篇 你应该很清楚了啊

 class Program
    
{
        
static void Main(string[] args)
        
{
            Computeruse com 
= new Computeruse();
            Adult me 
= new Adult();
            me.UseComputer(com);
            Child mybrother 
= new Child();
            mybrother.UseComputer(com);
            Console.ReadLine();
        }

    }

    
class Computeruse : IFinal
    
{
        
public Computeruse()
        
{
            Console.WriteLine(
"这个电脑我在用 别管我干嘛!!");
        }

        
IFinal 成员
    }

    
interface IFinal
    
{
        
void ToLearn();
        
void ToWork();
        
void ToFun();
    }

    
interface IComputerLearn:IFinal
    
{
        
void ToLearn();
    }

    
interface IComputerWork:IFinal
    
{
        
void ToWork();
    }

    
interface IComputerToFun:IFinal
    
{
        
void ToFun();
    }

    
class Adult
    
{
      
public void UseComputer(IFinal IFinal)
      
{
          IFinal.ToLearn();
          IFinal.ToFun();
      }

    }

      
class Child
      
{
          
public void UseComputer( IFinal IFinal)
          
{
              IFinal.ToFun();
          }

      }

这个应该是面向接口的最终版本了 希望下个项目会用到这个啊  呵呵~~

posted @ 2008-07-20 10:40  tf.li  阅读(357)  评论(8)    收藏  举报

刷新页面返回顶部