コード例 #1
0
        //Member Methods (Can do)

        //create method to initalize wallet. - Done
        //use .Add() to add coins to coins list for the number of coins you want. - Done


        private void FillWalletWithCoins()

        {
            for (int i = 0; i <= 16; i++)
            {
                Quarter quarter = new Quarter();
                coins.Add(quarter);
                coins.Add(new Nickel());
            }
            for (int i = 0; i < 10; i++)
            {
                Dime dime = new Dime();
                coins.Add(dime);
            }
            for (int i = 0; i < 50; i++)
            {
                Penny penny = new Penny();
                coins.Add(penny);
            }
        }
コード例 #2
0
 private void FillMachineRegister()
 //20 quarters, 10 dimes, 20 nickels, 50 pennies
 {
     for (int i = 0; i <= 20; i++)
     {
         Quarter quarter = new Quarter();
         register.Add(quarter);
         register.Add(new Nickel());
     }
     for (int i = 0; i <= 10; i++)
     {
         Dime dime = new Dime();
         register.Add(dime);
     }
     for (int i = 0; i <= 50; i++)
     {
         Penny penny = new Penny();
         register.Add(penny);
     }
 }