我不明白为什么我的派生类中会出现此错误来覆盖方法布尔值
public class HotRod : Racer
{
private bool blower = true || false;
public HotRod();
public HotRod(string racerName, int racerSpeed, Engine _engine);
{
racerName = name;
racerSpeed = speed;
Engine = engine;
}
public override bool IsDead()
{
Engine engine1 = new Engine();
Engine = engine1;
Random rnd = new Random();
rnd.NextDouble();
bool dead = false;
if (racerSpeed > 50 && rnd.NextDouble() > 0.6)
if (engine1.horsePower < 300 && blower == true)
dead = false;
else
dead = true;
else if (racerSpeed > 100 && rnd.NextDouble() > 0.4)
if (engine1.horsePower >= 300 && blower == true)
dead = true;
else
dead = false;
else
dead = false;
return dead;
}
public override string ToString()
{
string output;
output = "\n============ HotRod Information ============";
output += "\n\t Racer's Name:\t" + racerName;
output += "\n\t Car's Speed:\t" + carSpeed;
output += "\n\t Engine Cylinders:\t" + engineCylinders;
output += "\n\t Engine Horsepower:\t" + engineHorsePower;
output += "n\t Racer's Type:\t" + racerType;
output += "n\t Racer with Blower:\t" + carBlower;
output += "n\t Still Working?:\t" + IsDead;
return output;
}
}
错误也是布尔值,并显示预期的类、委托、枚举、接口或结构
我可以得到任何帮助吗
抽象类中的IsDead()是虚方法吗?
重写必须是虚方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)