我看了老半天了老是不对……谢过~~
namespace 接口
{
//定义接口
interface IMoveable
{
float Speed{get ;}
float MaxSpeed { get; set; }
void Run();
void Walk();
void Fly();
} class Dog:IMoveable
{
private float _MaxSpeed;
public float MaxSpeed
{
get {return this ._MaxSpeed;}
set {this ._MaxSpeed =value ;}
}
public float Speed
{
get {return 10.5f ;}
}
public void Run()
{
Console .WriteLine ("Dog.Run():a dog is runing");
}
public void Walk()
{
Console .WriteLine ("Dog.Walk():a dog is Walking");
}
public void Fly()
{
Console .WriteLine ("Dog.Fly():Dog can not fly!!");
}
} //
class Person: IMoveable //错误显示于此,说是不能实现接口成员IMverable
{
private float _MsxSpeed;
public float MsxSpeed
{
get {return this ._MsxSpeed;}
set {this ._MsxSpeed =value ;}
} public float Speed
{
get {return 20.5f;}
} public void Run()
{
Console .WriteLine ("Person.Run(): 一个人在奔跑");
}
public void Walk()
{
Console .WriteLine ("Person.Walk():一个人在走路");
}
public void Fly()
{
Console .WriteLine ("Person.Fly():人不会跑");
}
}
class Program
{ static void Main(string[] args)
{
//初始化
Person aPerson = new Person();
aPerson .MsxSpeed =50.f;
SthMove(aPerson);
IMoveable dog = new dog();
dog.MaxSpeed = 20.f;
SthMove(dog); }
static void SthMove(IMoveable mov)
{
Console .WriteLine ("This is a "+mov .GetType.Name);
Console .WriteLine (mov .GetType .Name+".Speed="+mov .Speed );
Console .WriteLine (mov .GetType .Name+".MaxSpeed="+mov .MaxSpeed );
mov .Run ();
mov .Walk();
mov .Fly ();
Console .WriteLine(); } }
}
在此谢过
namespace 接口
{
//定义接口
interface IMoveable
{
float Speed{get ;}
float MaxSpeed { get; set; }
void Run();
void Walk();
void Fly();
} class Dog:IMoveable
{
private float _MaxSpeed;
public float MaxSpeed
{
get {return this ._MaxSpeed;}
set {this ._MaxSpeed =value ;}
}
public float Speed
{
get {return 10.5f ;}
}
public void Run()
{
Console .WriteLine ("Dog.Run():a dog is runing");
}
public void Walk()
{
Console .WriteLine ("Dog.Walk():a dog is Walking");
}
public void Fly()
{
Console .WriteLine ("Dog.Fly():Dog can not fly!!");
}
} //
class Person: IMoveable //错误显示于此,说是不能实现接口成员IMverable
{
private float _MsxSpeed;
public float MsxSpeed
{
get {return this ._MsxSpeed;}
set {this ._MsxSpeed =value ;}
} public float Speed
{
get {return 20.5f;}
} public void Run()
{
Console .WriteLine ("Person.Run(): 一个人在奔跑");
}
public void Walk()
{
Console .WriteLine ("Person.Walk():一个人在走路");
}
public void Fly()
{
Console .WriteLine ("Person.Fly():人不会跑");
}
}
class Program
{ static void Main(string[] args)
{
//初始化
Person aPerson = new Person();
aPerson .MsxSpeed =50.f;
SthMove(aPerson);
IMoveable dog = new dog();
dog.MaxSpeed = 20.f;
SthMove(dog); }
static void SthMove(IMoveable mov)
{
Console .WriteLine ("This is a "+mov .GetType.Name);
Console .WriteLine (mov .GetType .Name+".Speed="+mov .Speed );
Console .WriteLine (mov .GetType .Name+".MaxSpeed="+mov .MaxSpeed );
mov .Run ();
mov .Walk();
mov .Fly ();
Console .WriteLine(); } }
}
在此谢过
解决方案 »
- 小弟有个疑问,忘各位解答!
- 系统找不到指定文件
- C#访问oracle的问题
- 各位老大,请问如何用程序不让电脑上网?谢谢啦~
- 请问大家c# primer plus 这本书怎么样啊?
- DATASET写XML 问题请教
- 如何获得其他应用exe程序的session
- 在windows窗体程序中,怎样实现右键点击事件。
- c#的一个小问题,请各位赐教,马上给分
- “System.Net.Mail.SmtpFailedRecipientsException”类型的未经处理的异常在 System.dll 中发生
- 还是登入界面的问题
- 请教OPenFileDialog类的InitialDirectory属性中路径保持和恢复的问题
{
private float ]_MsxSpeed;
public float MsxSpeed//是MaxSpeed
{
get {return this ._MsxSpeed;}
set {this ._MsxSpeed =value ;}
}
MsxSpeed
改后问题老多呢,不过都解决啦!!哈哈
谢谢啦哈
MsxSpeed
气死我了!我忘了