Advertisement
dobroslav-atanasov

Untitled

Mar 15th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. public abstract class Driver
  6. {
  7.     private string name;
  8.     private double totalTime;
  9.     private Car car;
  10.     private double fuelConsumptionPerKm;
  11.     private double speed;
  12.  
  13.     protected Driver(string name, Car car, double fuelConsumptionPerKm)
  14.     {
  15.         this.Name = name;
  16.         this.TotalTime = 0;
  17.         this.Car = car;
  18.         this.FuelConsumptionPerKm = fuelConsumptionPerKm;
  19.     }
  20.  
  21.     public string Name
  22.     {
  23.         get { return this.name; }
  24.         private set { this.name = value; }
  25.     }
  26.  
  27.     public double TotalTime
  28.     {
  29.         get { return this.totalTime; }
  30.         private set { this.totalTime = value; }
  31.     }
  32.  
  33.     public Car Car
  34.     {
  35.         get { return this.car; }
  36.         private set { this.car = value; }
  37.     }
  38.  
  39.     public double FuelConsumptionPerKm
  40.     {
  41.         get { return this.fuelConsumptionPerKm; }
  42.         private set { this.fuelConsumptionPerKm = value; }
  43.     }
  44.  
  45.     public virtual double Speed => (this.Car.Hp + this.Car.Tyre.Degradation) / this.Car.FuelAmount;
  46. }
  47.  
  48.  
  49. //--------------------------------------------------------------------------------------------------
  50. using System;
  51. using System.Collections.Generic;
  52. using System.Text;
  53.  
  54. public class AggressiveDriver : Driver
  55. {
  56.     public AggressiveDriver(string name, Car car)
  57.         : base(name, car, 2.7)
  58.     {
  59.     }
  60.  
  61.     public override double Speed => base.Speed * 1.3;
  62. }
  63.  
  64. //--------------------------------------------------------------------------------------------------
  65. using System;
  66. using System.Collections.Generic;
  67. using System.Text;
  68.  
  69. public class EnduranceDriver : Driver
  70. {
  71.     public EnduranceDriver(string name, Car car)
  72.         : base(name, car, 1.5)
  73.     {
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement