重写bool抽象方法时出错
本文关键字:出错 抽象方法 bool 重写 | 更新日期: 2023-09-27 18:29:26
我不明白为什么在我的派生类中会出现这个错误来覆盖方法布尔
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,并显示预期的类、委托、枚举、接口或结构
我能得到这个的任何帮助吗
抽象类中的IsDead()是虚拟方法吗?
覆盖必须是虚拟方法。