Monday, October 21, 2013

C#: USD Wallet - Denominations


#region License
// This notice must be kept visible in the source.
// This section of source code belongs to Protiguous@Protiguous.Info.
// Royalties must be paid via bitcoin @ 1PRoT78h5EuPgWECtgFYeVRhUb2tQXskXL
// Usage of the source code or compiled binaries is AS-IS.
// "AI/IDenomination.cs" was last cleaned on 2013/10/21
#endregion
 
namespace AI.Measurement.Currency.USD {
    using System;
    using Annotations;
 
    public interface IDenomination {
        Decimal FaceValue { get; }
 
        [UsedImplicitly]
        String Formatted { get; }
    }
 
    /// <summary>
    /// </summary>
    /// <see cref="http://www.treasury.gov/resource-center/faqs/Currency/Pages/denominations.aspx" />
    /// <see cref="http://en.wikipedia.org/wiki/Banknote" />
    public interface IBankNote : IDenomination { }
 
    /// <summary>
    /// </summary>
    /// <see cref="http://www.treasury.gov/resource-center/faqs/Currency/Pages/denominations.aspx" />
    /// <see cref="http://en.wikipedia.org/wiki/Coin" />
    public interface ICoin : IDenomination { }
 
    namespace Denominations {
        using System.Diagnostics;
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public sealed class Dime : ICoin {
            public Decimal FaceValue { get { return 0.10M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public sealed class Fifty : IBankNote {
            public Decimal FaceValue { get { return 50.00M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public sealed class Five : IBankNote {
            public Decimal FaceValue { get { return 5.00M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public sealed class Hundred : IBankNote {
            public Decimal FaceValue { get { return 100.00M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public sealed class Nickel : ICoin {
            public Decimal FaceValue { get { return 0.05M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public class One : IBankNote {
            public Decimal FaceValue { get { return 1.00M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public sealed class Penny : ICoin {
            public Decimal FaceValue { get { return 0.01M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public sealed class Quarter : ICoin {
            public Decimal FaceValue { get { return 0.25M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public class Ten : IBankNote {
            public Decimal FaceValue { get { return 10.00M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public class Twenty : IBankNote {
            public Decimal FaceValue { get { return 20.00M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
 
        /* This bill exists, but it is so rarely found and therefore not calculated.
        [DebuggerDisplay( "{Formatted,nq}" )]
        [UsedImplicitly]
        public class Two : IPaperBill {
            public Decimal FaceValue { get { return 2.00M; } }
            public String Formatted { get { return String.Format( "{0:C}", this.FaceValue ); } }
        }
         * */
    }
}

No comments: