Advertisement
dobroslav-atanasov

Untitled

Mar 14th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. // TYRE CLASS
  2. //-----------------------------------------------------------------------------------
  3. public abstract class Tyre
  4. {
  5.     public abstract string Name { get; }
  6.  
  7.     private double hardness;
  8.     public double Hardness
  9.     {
  10.         get { return hardness; }
  11.         protected set { hardness = value; }
  12.     }
  13.  
  14.     private double degradation;
  15.     public double Degradation
  16.     {
  17.         get { return degradation; }
  18.         protected set { degradation = value; }
  19.     }
  20.  
  21.     protected Tyre(double hardness)
  22.     {
  23.         this.Hardness = hardness;
  24.         this.Degradation = 100;
  25.     }
  26.     public virtual void DegradeTyre()
  27.     {
  28.         this.Degradation = this.Degradation - this.Hardness;
  29.         if (this.Degradation < 0)
  30.         {
  31.             ////throw new Exception();
  32.         }
  33.     }
  34. }
  35.  
  36. //-----------------------------------------------------------------------------------
  37. //UltrasoftTyre
  38. public class UltrasoftTyre
  39.     : Tyre
  40. {
  41.     public UltrasoftTyre(double hardness,double grip) : base(hardness)
  42.     {
  43.         this.Grip = grip;
  44.         this.Name = "Ultrasoft";
  45.     }
  46.  
  47.     private double grip;
  48.     public double Grip
  49.     {
  50.         get { return grip; }
  51.         protected set { grip = value; }
  52.     }
  53.  
  54.     public override string Name { get; }
  55.  
  56.     public override void DegradeTyre()
  57.     {
  58.         this.Degradation = this.Degradation - (this.Hardness + this.Grip);
  59.         if (this.Degradation < 30)
  60.         {
  61.             ////throw new Exception();
  62.         }
  63.     }
  64. }
  65.  
  66. //-----------------------------------------------------------------------------------
  67. //HardTyre
  68. public class HardTyre
  69.     : Tyre
  70. {
  71.     public HardTyre(double hardness) : base(hardness)
  72.     {
  73.         this.Name = "Hard";
  74.     }
  75.  
  76.     public override string Name { get; }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement