예제 #1
0
        //Properties



        //Contructors initialize values upon instantiation.


        //Methods do something.
        public void DispenseCoins()
        {
            //Will these objects retain their data even though they're instantiated in a method and as member variables?
            Dime    Dimes    = new Dime();
            Nickle  Nickles  = new Nickle();
            Penny   Pennies  = new Penny();
            Quarter Quarters = new Quarter();

            for (int index = 0; index < 20; index++)
            {
                List <Coin> Coin = new List <Coin>();
                register.Add("Quarters");//This error under Add occurred when I instantiated the lists.
                Console.WriteLine(index);
                balanceOfQuarters = index;
            }

            for (int index = 0; index < 10; index++)
            {
                List <Coin> Coin = new List <Coin>();
                register.Add("Dimes");
                Console.WriteLine(index);
                balanceOfDimes = index;
            }

            for (int index = 0; index < 20; index++)
            {
                List <Coin> Coin = new List <Coin>();
                register.Add("Nickles");
                Console.WriteLine(index);
                balanceOfNickels = index;
            }

            for (int index = 0; index < 50; index++)
            {
                List <Coin> register = new List <Coin>();
                register.Add("Pennies");
                Console.WriteLine(index);
                balanceOfPennies = index;
            }
            Console.WriteLine();
        }
예제 #2
0
        //Methods do something.
        public void KeepTrackOfCoins()
        {
            Quarter Quarters = new Quarter();
            Dime    Dimes    = new Dime();
            Nickle  Nickles  = new Nickle();
            Penny   Pennies  = new Penny();

            for (int index = 0; index < 12; index++)
            {
                List <Coin> Coin = new List <Coin>();
                Coin.Add("Quarters");//This error under Add occurred when I instantiated the lists.
                Console.WriteLine(index);
                walletBalanceOfQuarters = index;
            }

            for (int index = 0; index < 10; index++)
            {
                List <Coin> Coin = new List <Coin>();
                Coin.Add("Dimes");
                Console.WriteLine(index);
                walletBalanceOfDimes = index;
            }

            for (int index = 0; index < 15; index++)
            {
                List <Coin> Coin = new List <Coin>();
                Coin.Add("Nickles");
                Console.WriteLine(index);
                walletBalanceOfNickels = index;
            }

            for (int index = 0; index < 25; index++)
            {
                List <Coin> register = new List <Coin>();
                Coin.Add("Pennies");
                Console.WriteLine(index);
                walletBalanceOfPennies = index;
            }
            Console.WriteLine();
        }