private void CreateCreditButtonDictionary() { // Add the buttons to a dictionary creditButtons.Add(buttonDollar, CurrencyHelper.GetUSDCommonBills().Where(x => x.Name == "one dollar bill").First()); creditButtons.Add(buttonQuarter, coins.Where(x => x.Name == "quarter").First()); creditButtons.Add(buttonDime, coins.Where(x => x.Name == "dime").First()); creditButtons.Add(buttonNickel, coins.Where(x => x.Name == "nickel").First()); creditButtons.Add(buttonPenny, coins.Where(x => x.Name == "penny").First()); }
private void GiveChange(decimal unusedCredit) { var change = CurrencyHelper.CalculateChange(unusedCredit, coins); int quarters = change.Where(x => x.Name == "quarter").First().Quantity; int dimes = change.Where(x => x.Name == "dime").First().Quantity; int nickels = change.Where(x => x.Name == "nickel").First().Quantity; int pennies = change.Where(x => x.Name == "penny").First().Quantity; credit = 0; UpdateCredit(); ToggleChangeVisible(true); lblChange.Text = "Total Change: " + unusedCredit; lblQuaters.Text = "Quaters: " + quarters; lblDimes.Text = "Dimes: " + dimes; lblNickels.Text = "Nickels: " + nickels; lblPennies.Text = "Pennies: " + pennies; }