コード例 #1
0
        public Wallet()
        {
            coinsInWallet = new List <Coin>();
            {
                for (int i = 0; i < 50; i++)
                {
                    Penny penny = new Penny();
                    coinsInWallet.Add(penny);
                }

                for (int i = 0; i < 20; i++)
                {
                    Nickle nickle = new Nickle();
                    coinsInWallet.Add(nickle);
                }

                for (int i = 0; i < 10; i++)
                {
                    Dime dime = new Dime();
                    coinsInWallet.Add(dime);
                }

                for (int i = 0; i < 20; i++)
                {
                    Quarter quarter = new Quarter();
                    coinsInWallet.Add(quarter);
                }
            }
        }
コード例 #2
0
        public SodaMachine()
        {
            register = new List <Coin>();
            {
                for (int i = 0; i < 50; i++)
                {
                    Penny penny = new Penny();
                    register.Add(penny);
                }

                for (int i = 0; i < 20; i++)
                {
                    Nickle nickle = new Nickle();
                    register.Add(nickle);
                }

                for (int i = 0; i < 10; i++)
                {
                    Dime dime = new Dime();
                    register.Add(dime);
                }

                for (int i = 0; i < 20; i++)
                {
                    Quarter quarter = new Quarter();
                    register.Add(quarter);
                }
            }


            inventory = new List <Can>();
            {
                for (int i = 0; i < 10; i++)
                {
                    Cola cola = new Cola();
                    inventory.Add(cola);
                }

                for (int i = 0; i < 10; i++)
                {
                    OrangeSoda orangeSoda = new OrangeSoda();
                    inventory.Add(orangeSoda);
                }

                for (int i = 0; i < 10; i++)
                {
                    RootBeer rootBeer = new RootBeer();
                    inventory.Add(rootBeer);
                }
            }
        }
コード例 #3
0
 public Penny()
 {
     value     = 0.01;
     this.name = "Penny";
     Coin penny = new Penny();
 }