public static double GetDenominationValuePerUnit(DenominationType value) { switch (value) { case DenominationType.OneP: return(0.01); case DenominationType.TwoP: return(0.02); case DenominationType.FiveP: return(0.05); case DenominationType.TenP: return(0.1); case DenominationType.TwentyP: return(0.2); case DenominationType.FiftyP: return(0.5); case DenominationType.OnePound: return(1); case DenominationType.TwoPound: return(2); case DenominationType.FivePound: return(5); case DenominationType.TenPound: return(10); case DenominationType.TwentyPound: return(20); case DenominationType.FiftyPound: return(50); default: return(0); } }
/// <summary> /// Initializes a new instance of the Denomination class. /// </summary> /// <param name="id">The id of the denomination.</param> /// <param name="type">The type of the denomination (i.e. coin, bill, /// etc.)</param> /// <param name="name">The name of the denomination.</param> /// <param name="value">The value of the denomination in relation to /// the currency's base denomination.</param> /// <param name="count">The count of this denomination.</param> /// <param name="allowAcceptor">Whether this denomination can be /// accepted by the system.</param> /// <param name="isActive">Whether this denomination is active in the /// system.</param> /// <param name="order">Order</param> public Denomination(int id, DenominationType type, string name, decimal value, int count, bool allowAcceptor, bool isActive, short order = 0) { Id = id; Type = type; Name = name; Value = value; Count = count; AllowAcceptor = allowAcceptor; IsActive = isActive; Order = order; }
protected static double WithdrawInChosenDenomination(double amountLeftToWithdraw, Cash cash, DenominationType denomination) { if (amountLeftToWithdraw > 0) { int NumberOfItemsInChosenDenomination = (int)(amountLeftToWithdraw / ExtensionMethods.GetDenominationValuePerUnit(denomination)); if (NumberOfItemsInChosenDenomination > 0) { Denomination item = new Denomination { Type = denomination, Count = NumberOfItemsInChosenDenomination }; cash.CoinOrNotes.Add(item); amountLeftToWithdraw = Math.Round(amountLeftToWithdraw - item.Value * item.Count, 2); } } return(amountLeftToWithdraw); }
public Card(SuitType suit, DenominationType denomination) { Suit = suit; Denomination = denomination; }