ss3434

Untitled

Jul 7th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace NeedForSpeed
  6. {
  7. public class Vehicle
  8. {
  9. private const double DefaultFuelConsumption = 1.25;//konstanta
  10.  
  11. public Vehicle(int horsePower, double fuel)
  12. {
  13. this.HorsePower = horsePower;
  14. this.Fuel = fuel;
  15.  
  16. //this.FuelConsumption=
  17. }
  18.  
  19.  
  20.  
  21. public virtual double FuelConsumption => DefaultFuelConsumption;//vzima konstantata za da moje v vseki klass da ima razli4en razhod na gorivo
  22.  
  23. public int HorsePower { get; set; }
  24.  
  25. public double Fuel { get; set; }
  26.  
  27.  
  28.  
  29. public virtual void Drive(double kilometers)
  30. {
  31. bool canDrive = this.Fuel - kilometers * this.FuelConsumption >= 0;
  32.  
  33. if (canDrive)//proverka dali e nqma da mu svar6i benzina
  34. {
  35. this.Fuel -= kilometers * this.FuelConsumption;
  36.  
  37. }
  38.  
  39.  
  40. }
  41.  
  42. }
  43. }
Add Comment
Please, Sign In to add comment