static void Main(string[] args)
    {
        IMoney    graphical_money_obj = null;
        int       currency_display_value, sum = 0;
        const int ONE_MILLION = 10000; // Assume this is one million

        int[]        currency_denominations = new[] { 1, 5, 10, 20, 50, 100 };
        MoneyFactory moneyFactory           = new MoneyFactory();

        Random rand = new Random();

        while (sum <= ONE_MILLION)
        {
            currency_display_value = currency_denominations[rand.Next(0, currency_denominations.Length)];

            if (currency_display_value == 1 || currency_display_value == 5)
            {
                graphical_money_obj = moneyFactory.GetMoneyToDisplay(EnMoneyType.Metallic);
            }
            else
            {
                graphical_money_obj = moneyFactory.GetMoneyToDisplay(EnMoneyType.Paper);
            }

            graphical_money_obj.GetDisplayOfMoneyFalling(currency_display_value);

            sum = sum + currency_display_value;
        }

        Console.WriteLine("Total number of objects created is: " + MoneyFactory.ObjectsCount.ToString());

        Console.ReadLine();
    }
Example #2
0
        public static void Main(string[] args)
        {
            const int ONE_THOUSAND = 1000;

            int[]        currencyDenominations = new[] { 1, 5, 10, 20, 50, 100 };
            MoneyFactory moneyFactory          = new MoneyFactory();
            int          sum = 0;

            while (sum <= ONE_THOUSAND)
            {
                IMoney graphicalMoneyObj = null;
                Random rand = new Random();
                int    currencyDisplayValue = currencyDenominations[rand.Next(0, currencyDenominations.Length)];

                if (currencyDisplayValue == 1 || currencyDisplayValue == 5)
                {
                    graphicalMoneyObj = moneyFactory.GetMoneyToDisplay(EnMoneyType.Metallic);
                }
                else
                {
                    graphicalMoneyObj = moneyFactory.GetMoneyToDisplay(EnMoneyType.Paper);
                }

                graphicalMoneyObj.GetDisplayOfMoneyFalling(currencyDisplayValue);
                sum += 1;
            }

            Console.WriteLine("Total Objects Created = " + MoneyFactory.ObjectsCount.ToString());
            Console.ReadLine();
        }