0

我不明白为什么我的派生类中有这个错误来覆盖方法布尔值

        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 并显示 Expected class、delegate、enum、interface 或 struct

我能得到任何帮助吗

4

1 回答 1

1

抽象类中的 IsDead() 是虚方法吗?

覆盖必须是虚方法。

于 2013-08-28T00:00:25.493 回答