public static void InsertCoins( this IVendingMachineService service, CoinType coinType, int numberOfCoins ) { for (var i = 0; i < numberOfCoins; i++) { service.InsertCoinAsync(coinType.ToDecimal()); } }
private static (decimal rest, int coinAmount) GetCoinChange( this decimal val, CoinType coinType) { var coinTypeVal = coinType.ToDecimal(); var coins = 0; while (val >= coinTypeVal) { coins = coins + 1; val = val - coinTypeVal; } return(val, coins); }
private decimal ProcessReturnWallet( Dictionary <CoinType, Stack <Coin> > machineWallet, Dictionary <CoinType, Stack <Coin> > returnWallet, CoinType coinType, decimal changeVal) { var coinTypeVal = coinType.ToDecimal(); while (changeVal >= coinTypeVal && machineWallet[coinType].Count > 0) { var fiftyCentCoin = machineWallet[coinType].Pop(); returnWallet[coinType].Push(fiftyCentCoin); changeVal = changeVal - coinTypeVal; } return(changeVal); }
public Coin(CoinType coinType) { Name = coinType; Value = coinType.ToDecimal(); }