Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace NeedForSpeed
- {
- public class Vehicle
- {
- private const double DefaultFuelConsumption = 1.25;//konstanta
- public Vehicle(int horsePower, double fuel)
- {
- this.HorsePower = horsePower;
- this.Fuel = fuel;
- //this.FuelConsumption=
- }
- public virtual double FuelConsumption => DefaultFuelConsumption;//vzima konstantata za da moje v vseki klass da ima razli4en razhod na gorivo
- public int HorsePower { get; set; }
- public double Fuel { get; set; }
- public virtual void Drive(double kilometers)
- {
- bool canDrive = this.Fuel - kilometers * this.FuelConsumption >= 0;
- if (canDrive)//proverka dali e nqma da mu svar6i benzina
- {
- this.Fuel -= kilometers * this.FuelConsumption;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment