/*
           * . Accept a flat file as input
          +	1. Each line will contain the amount owed and the amount paid separated by a comma (for example: 2.13,3.00)
          +	2. Expect that there will be multiple lines
           */
        public string ProcessAmounts(TransactionAmounts transactionAmounts)
        {
            string str;
            AbsTranslator translator;
                decimal d = new CashRegister().CalculateChange(transactionAmounts);
                if (d > 0)
                {
                    if ((d % 3) == 0)
                    {
                        translator = new TranslatorFactory().GetTranslator(MoneyConstants.RandomUSD);
                        str = translator.TranslateAmount(d);
                    }
                    else
                    {
                        translator = new TranslatorFactory().GetTranslator(MoneyConstants.USD);
                        str = translator.TranslateAmount(d);
                    }
                }
                else if (d == 0)
                {
                    str = "You have paid the exact amount";
                }
                else
                {
                    translator = new TranslatorFactory().GetTranslator(MoneyConstants.USD);
                    str = "You still owe "+translator.TranslateAmount(Math.Abs(d));
                }

            return str;
        }
Пример #2
0
        public void B_TestCalculateChange()
        {
            var cr = new CashRegister();

            decimal d = cr.CalculateChange(
                new TransactionAmounts()
                {
                    AmountOwed = 2.12m,
                    AmountPaid = 3.00m
                });

            Assert.AreEqual(d,.88m);
        }