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