我想请教一下
你们做方法的继承时
子类和父类中的override 关键字时
是怎么处理
子类中没有可重写的
麻烦多多指教啊
可是我还是不是很清楚耶,能帮我把以下的程序修改一下吗?
using System;
class Boat
{
private string registrationNo,kength,manufacturer,year;
public Boat()
{
RegistrationNo="56874261";
Kength="250";
Manufacturer="下桑电器有限公司";
Year="2006";
}
public Boat(string myRegistrationNo,string myKength,string myManufacturer,string myYear )
{
registrationNo=myRegistrationNo;
kength=myKength;
manufacturer=myManufacturer;
year=myYear;
}
public string RegistrationNo
{
set{ registrationNo=value;}
get{return registrationNo;}
}
public string Kength
{
set{ kength=value;}
get{return kength;}
}
public string Manufacturer
{
set{ manufacturer=value;}
get{return manufacturer;}
}
public string Year
{
set{ year=value;}
get{return year;}
}
public void ToallString()
{
Console.Write("注册号:{0},长:{1}米,制照商:{2},{3}年",registrationNo,kength,manufacturer,year);
}
}
class Sailboat:Boat
{
private string keelDepth,none,outboard;
public Sailboat()
{}
public Sailboat(string myKeelDepth,string myNone,string myOutboard)
{
keelDepth=myKeelDepth;
none=myNone;
outboard=myOutboard;
}
public string KeelDepth
{
set{keelDepth=value;}
get{return keelDepth;}
}
public string None
{
set{none=value;}
get{return none;}
}
public string Outboard
{
set{outboard=value;}
get{return outboard;}
}
public void ToallString()
{
Console.Write("龙骨深度:{0},帆船编号:{1},马达类型:{2}",keelDepth,none,outboard);
}
}
class Powerboat:Boat
{}
class Test
{
public static void Main()
{
Boat b1=new Boat("20056","100","广州电器有限公司","2007");
b1.ToallString();
Boat b2=new Boat();
b2.ToString();
Console.Read();
}
}
这个程序有错 ,但是我又改不出来,麻烦你了,帮我检查一下好吗?我还是一个新新手.拜托了.