Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TYRE CLASS
- //-----------------------------------------------------------------------------------
- public abstract class Tyre
- {
- public abstract string Name { get; }
- private double hardness;
- public double Hardness
- {
- get { return hardness; }
- protected set { hardness = value; }
- }
- private double degradation;
- public double Degradation
- {
- get { return degradation; }
- protected set { degradation = value; }
- }
- protected Tyre(double hardness)
- {
- this.Hardness = hardness;
- this.Degradation = 100;
- }
- public virtual void DegradeTyre()
- {
- this.Degradation = this.Degradation - this.Hardness;
- if (this.Degradation < 0)
- {
- ////throw new Exception();
- }
- }
- }
- //-----------------------------------------------------------------------------------
- //UltrasoftTyre
- public class UltrasoftTyre
- : Tyre
- {
- public UltrasoftTyre(double hardness,double grip) : base(hardness)
- {
- this.Grip = grip;
- this.Name = "Ultrasoft";
- }
- private double grip;
- public double Grip
- {
- get { return grip; }
- protected set { grip = value; }
- }
- public override string Name { get; }
- public override void DegradeTyre()
- {
- this.Degradation = this.Degradation - (this.Hardness + this.Grip);
- if (this.Degradation < 30)
- {
- ////throw new Exception();
- }
- }
- }
- //-----------------------------------------------------------------------------------
- //HardTyre
- public class HardTyre
- : Tyre
- {
- public HardTyre(double hardness) : base(hardness)
- {
- this.Name = "Hard";
- }
- public override string Name { get; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement