Пример #1
0
        private void make_change(double value)
        {
            Denomination tempd = null;
            Change       tempc = null;

            while (value >= 0)
            {
                tempd = currency.get_closest_denomination(value);
                if (tempd != null)
                {
                    tempc = new Change(tempd.value, tempd.name, tempd.plural);

                    while ((value - tempd.value) >= 0.0)
                    {
                        tempc.count++;
                        value -= tempd.value;
                    }
                    change.Add(tempc);
                }
                else if ((value != 0) && (tempd != null))
                {
                    throw new System.ArgumentException("Change cannot be made with this currency for this transaction", "original");
                }
                else
                {
                    break;
                }
            }
            find_extra_penny(value);
        }
Пример #2
0
        private void init_uncommon_denominations()//adds 2 dollar bills and half dollar coins to the list
        {
            Denomination temp;

            temp = new Denomination(0.50, "Half Dollar", "Half Dollars");
            denominations.Add(temp);
            temp = new Denomination(2.00, "Two Dollar Bill", "Two Dollar Bills");
            denominations.Add(temp);
        }
Пример #3
0
        private void init_high_values()//adds 50s and 100s
        {
            Denomination temp;

            temp = new Denomination(50, "Fifty Dollar Bill", "Fifty Dollar Bills");
            denominations.Add(temp);
            temp = new Denomination(100, "Hundred Dollar Bill", "Hundred Dollar Bills");
            denominations.Add(temp);
        }
Пример #4
0
        private void init_more_bills()//adds 5s, 10s, and 20s
        {
            Denomination temp;

            temp = new Denomination(5, "Five Dollar Bill", "Five Dollar Bills");
            denominations.Add(temp);
            temp = new Denomination(10, "Ten Dollar Bill", "Ten Dollar Bills");
            denominations.Add(temp);
            temp = new Denomination(20, "Twenty Dollar Bill", "Twenty Dollar Bills");
            denominations.Add(temp);
        }
Пример #5
0
        private void init_discontinued()//adds 500s, 1000s, 5000s, and 10000s
        {
            Denomination temp;

            temp = new Denomination(500, "Five Hundred Dollar Bill", "Five Hundred Dollar Bills");
            denominations.Add(temp);
            temp = new Denomination(1000, "Thousand Dollar Bill", "Thousand Dollar Bills");
            denominations.Add(temp);
            temp = new Denomination(5000, "Five Thousand Dollar Bill", "Five Thousand Dollar Bills");
            denominations.Add(temp);
            temp = new Denomination(10000, "Ten Thousand Dollar Bill", "Ten Thousand Dollar Bills");
            denominations.Add(temp);
        }