예제 #1
0
 public static void InsertCoins(
     this IVendingMachineService service,
     CoinType coinType,
     int numberOfCoins
     )
 {
     for (var i = 0; i < numberOfCoins; i++)
     {
         service.InsertCoinAsync(coinType.ToDecimal());
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
파일: Coin.cs 프로젝트: harishamdani/vms
 public Coin(CoinType coinType)
 {
     Name  = coinType;
     Value = coinType.ToDecimal();
 }