using System;

namespace Volpe.Cafe
{
    /// <summary>
    /// Represents an object that stores the various credits and adjustments values that a manufacturer may use toward
    /// compliance with either NHTSA's CAFE standards or EPA's CO-2 standards. The credits and adjustments typically
    /// correspond to the vehicle technology improvements that are not otherwise captured on the test cycle, or to
    /// technologies that include an additional incentive (via an extra credit) to promote their adoption within the
    /// fleet.
    /// </summary>
    [Serializable]
    public struct OffCycleValues
    {
        /// <summary>
        /// Initializes a new <see cref="OffCycleValues"/> instance using the specified parameters.
        /// </summary>
        public OffCycleValues(double acEfficiency, double acLeakage, double offCycle, double fullSizePickup)
        {
            this.AcEfficiency = acEfficiency;
            this.AcLeakage = acLeakage;
            this.OffCycle = offCycle;
            this.FullSizePickup = fullSizePickup;
        }

        /// <summary>
        /// Represents an empty <see cref="OffCycleValues"/> instance. This value is read-only.
        /// </summary>
        public static readonly OffCycleValues Empty = new OffCycleValues(0, 0, 0, 0);

        /// <summary>
        /// Gets or sets the credit or adjustment value applicable to the technologies associated with the improvements
        /// in air conditioning efficiency.
        /// </summary>
        /// <remarks>
        /// This value is typically applicable toward compliance with either NHTSA's CAFE standards or EPA's CO-2
        /// standards.
        /// </remarks>
        public double AcEfficiency { get; set; }

        /// <summary>
        /// Gets or sets the credit or adjustment value applicable to the technologies associated with the improvements
        /// in air conditioning leakage.
        /// </summary>
        /// <remarks>
        /// This value is typically applicable toward compliance with EPA's CO-2 standards.
        /// </remarks>
        public double AcLeakage { get; set; }

        /// <summary>
        /// Gets or sets the credit or adjustment value applicable to the various "off-cycle" technologies.
        /// </summary>
        /// <remarks>
        /// This value is typically applicable toward compliance with either NHTSA's CAFE standards or EPA's CO-2
        /// standards.
        /// </remarks>
        public double OffCycle { get; set; }

        /// <summary>
        /// Gets or sets the credit or adjustment value applicable to full-size pickups due to application of advanced
        /// fuel improving technologies.
        /// </summary>
        /// <remarks>
        /// This value is typically applicable toward compliance with either NHTSA's CAFE standards or EPA's CO-2
        /// standards.
        /// </remarks>
        public double FullSizePickup { get; set; }

        /// <summary>
        /// Gets the combined total of all off-cycle credits and adjustments values.
        /// </summary>
        public double Total => this.AcEfficiency + this.AcLeakage + this.OffCycle + this.FullSizePickup;

        /// <summary>
        /// Returns the string representation of this <see cref="OffCycleValues"/> instance.
        /// </summary>
        /// <returns>
        /// The string representation of the <see cref="OffCycleValues"/> instance.
        /// </returns>
        public override string ToString()
        {
            return $"{{AcEfficiency={this.AcEfficiency}, AcLeakage={this.AcLeakage}, "
                 + $"OffCycle={this.OffCycle}, FullSizePickup={this.FullSizePickup}}}";
        }

    }
}
