刚才对面向接口充满了疑惑 经过自己的仔细推敲 加上 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();
}
}
这个应该是面向接口的最终版本了 希望下个项目会用到这个啊 呵呵~~
{
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();
}
}