Пример #1
0
        public ChangeResponse CoinReturn(ChangeRequest transaction)
        {
            var coinCount = new Change();

            coinCount.SilverDollars = transaction.ChangeOwed/100;
            coinCount.Quarters = (transaction.ChangeOwed - coinCount.SilverDollars*100)/25;
            coinCount.Dimes = (transaction.ChangeOwed - (coinCount.SilverDollars*100 + coinCount.Quarters*25))/10;
            coinCount.Nickels = (transaction.ChangeOwed - (coinCount.SilverDollars*100 + coinCount.Quarters*25 + coinCount.Dimes*10))/5;
            coinCount.Pennies = (transaction.ChangeOwed -
                                (coinCount.SilverDollars*100 + coinCount.Quarters*25 + coinCount.Dimes*10 +
                                 coinCount.Nickels*5));

            var changeResponse = new ChangeResponse();
            changeResponse.Coins = coinCount;
            changeResponse.Item = transaction.Item;
            changeResponse.ChangeOwed = transaction.ChangeOwed;
            changeResponse.Payment = transaction.Payment;
            return changeResponse;
        }
Пример #2
0
 private void ChangePrinter(ChangeResponse changeResponse)
 {
     Console.WriteLine("\nYou've got {0:c} coming to you in the form of: ", (decimal)changeResponse.ChangeOwed/100);
        Console.WriteLine("Silver Dollars - {0}\nQuarters - {1}\nDimes - {2}\nNickels - {3}\nPennies - {4}", changeResponse.Coins.SilverDollars, changeResponse.Coins.Quarters, changeResponse.Coins.Dimes, changeResponse.Coins.Nickels, changeResponse.Coins.Pennies);
 }