我不明白为什么我的派生类中存在这个错误以覆盖方法boolean
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;
}
}
错误太bool并且说预期类,委托,枚举,接口或结构
我可以得到任何帮助吗
答案 0 :(得分:1)
抽象类中的IsDead()是虚方法吗?
覆盖必须是虚方法。