using System; using System.Xml.Serialization; namespace TransportGame.Primitives { /// /// Interval /// public class Interval { #region Properties /// /// Gets the minimum value of the interval /// [XmlAttribute("min")] public float Min { get; set; } /// /// Gets the maximum value of the interval /// [XmlAttribute("max")] public float Max { get; set; } #endregion #region Other properties /// /// Gets or sets the length of the interval /// [XmlIgnore] public float Length { get { return Max - Min; } set { Max = Min + value; } } #endregion #region Constructors /// /// Initializes interval /// public Interval() { Min = 0; Max = 1; } /// /// Initializes interval /// /// Minimum value /// Maximum value public Interval(float min, float max) { Min = min; Max = max; } #endregion #region Operations /// /// Tests if interval contains value /// /// /// public bool Contains(float value) { return (value >= Min && value <= Max); } #endregion #region Object overrides /// /// Gets string representation /// /// public override string ToString() { return String.Format("[{0}, {1}]", Min, Max); } #endregion } }