Пример #1
0
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            try
            {
                Withdrawal       calc        = new Withdrawal();
                int              valueDrawee = Convert.ToInt32(txtValueDrawee.Text);
                Tuple <int, int> tupleRemainder;

                tupleRemainder = calc.Calculate(valueDrawee, Withdrawal.enumMoneyValue.fifty, amountCashValue50);

                txtAmountCashValue50.Text = tupleRemainder.Item1.ToString();

                tupleRemainder            = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Twenty, amountCashValue20);
                txtAmountCashValue20.Text = tupleRemainder.Item1.ToString();

                tupleRemainder            = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Ten, amountCashValue10);
                txtAmountCashValue10.Text = tupleRemainder.Item1.ToString();

                tupleRemainder           = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.fife, amountCashValue5);
                txtAmountCashValue5.Text = tupleRemainder.Item1.ToString();

                tupleRemainder           = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Two, 0);
                txtAmountCashValue2.Text = tupleRemainder.Item1.ToString();



                CacheCashValues();
            }
            catch (Exception ex)
            {
                RetriaverCach();

                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
        public void Calculate()
        {
            Withdrawal calc = new Withdrawal();

            Tuple <int, int> tupleRemainder = calc.Calculate(219, Withdrawal.enumMoneyValue.fifty, null);

            Assert.AreEqual(4, tupleRemainder.Item1);

            tupleRemainder = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Twenty, null);

            Assert.AreEqual(0, tupleRemainder.Item1);

            tupleRemainder = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Ten, null);
            Assert.AreEqual(1, tupleRemainder.Item1);

            tupleRemainder = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.fife, null);
            Assert.AreEqual(1, tupleRemainder.Item1);

            tupleRemainder = calc.Calculate(tupleRemainder.Item2, Withdrawal.enumMoneyValue.Two, null);

            Assert.AreEqual(2, tupleRemainder.Item1);
        }