我正在建模一个模拟汽车和卡车的驾驶和加油的程序。这就是我到目前为止所做的:
public abstract class Vehicle
{
protected Vehicle(double fuelQuantity, double fuelConsumption)
{
this.FuelQuantity = fuelQuantity;
this.FuelConsumption = fuelConsumption;
}
public double FuelQuantity { get; protected set; }
public double FuelConsumption { get; protected set; }
public abstract string Drive(double distance);
public abstract void Refuel(double liters);
}
public class Car : Vehicle
{
public Car(double fuelQuantity, double fuelConsumption) : base (fuelQuantity, fuelConsumption)
{
}
public override string Drive(double distance)
{
}
public override void Refuel(double liters)
{
}
}
所以,我想增加0.9升汽车的油耗值(现在是夏天,所以汽车使用空调)。哪里可以做到这一点?我不想在构造函数中这样做,因为我认为这样不行。
慕码人2483693
眼眸繁星
慕田峪9158850
相关分类