private static void ProcessCommandLinePurchase(string[] args, CanRack vendingMachine, PurchasePrice priceOfOneSoda, CoinBox coinBox) {
            if (args.Length < 2 ) {
                WriteLine("Invalid Command line parameters: must be in the form 'flavor coin1 [coin2]...");
                return;
            }

            Flavor flavor = Flavor.LEMON;
            bool isValidFlavor = vendingMachine.StocksThisFlavor(args[0], ref flavor);
            if (!isValidFlavor) {
                WriteLine($"{args[0]} is not a valid flavor name.");
                return;
            }

            coinBox = AddCoinsToCoinBoxFromListOfCoins(string.Join(" ", args, 1, args.Length - 1), coinBox);
            decimal valueOfCoins = 0;
            for (int i=1; i<args.Length; i++) {
                valueOfCoins += new Coin(args[i]).ValueOf;
            }

            decimal amountOfChange = valueOfCoins - priceOfOneSoda.PriceInDollars;
            if (amountOfChange < 0) {
                WriteLine($"You are short {-amountOfChange:C}.");
            } else {
                vendingMachine.RemoveACanOf(flavor);
                WriteLine($"Thanks. Here is your {flavor} soda.\n");
                WriteLine($"\nThe coin box contains \n{coinBox.ToString()}");
                if (amountOfChange > 0) {
                    WriteLine($"and here is your change of {amountOfChange:C}.");
                }
            }
        }
 public bool Withdraw(Coin.Denomination coinType) {
     if (CoinCount(coinType) > 0) {
         box[coinType]--;
         NotifyPropertyChanged();
         return true;
     } else {
         return false;
     }
 }
 private int CoinCount(Coin.Denomination kindOfCoin) {
     var result = from coinType in box
                  where coinType.Key == kindOfCoin
                  select coinType.Value;
     return result.Sum();
 }
 public void Deposit(Coin.Denomination coinType) {
     box[coinType]++;
     NotifyPropertyChanged();
 }