예제 #1
0
        public static Coin ChooseCoinsForPayment()
        {
            Console.WriteLine("Enter coins for payment.");
            Console.WriteLine("Type 'penny', 'nickle', 'dime', 'quarter' to enter payment");
            string input = Console.ReadLine();
            Coin   coin  = null;

            switch (input)
            {
            case "penny":
                coin = new Penny();
                break;

            case "nickle":
                coin = new Nickle();
                break;

            case "Dime":
                coin = new Dime();
                break;

            case "quarter":
                coin = new Quarter();
                break;

            default:
                Console.WriteLine("Invalid entry");
                ChooseCoinsForPayment();
                break;
            }
            return(coin);
        }
예제 #2
0
        // constructor (SPAWN)
        public SodaMachine()
        {
            hopperIn  = new List <Coin>();
            hopperOut = new List <Coin>();
            register  = new List <Coin>();
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickel  = new Nickel();
            Penny   penny   = new Penny();

            AddToInventory(quarter, 20);
            AddToInventory(dime, 10);
            AddToInventory(nickel, 20);
            AddToInventory(penny, 50);

            inventory = new List <Can>();
            Cola       cola       = new Cola();
            OrangeSoda orangeSoda = new OrangeSoda();
            RootBeer   rootBeer   = new RootBeer();

            AddToInventory(cola, 5);
            AddToInventory(orangeSoda, 5);
            AddToInventory(rootBeer, 5);

            cardPaymentBalance = 0;
        }
예제 #3
0
파일: Wallet.cs 프로젝트: royalisme7/soda
        public void MixChange()
        {
            for (int i = 0; i < 8; i++)
            {
                Coin quarter = new Quarter();
                MyChange.Add(quarter);
            }
            for (int i = 0; i < 10; i++)
            {
                Coin dime = new Dime();
                MyChange.Add(dime);
            }

            for (int i = 0; i < 20; i++)
            {
                Coin nickel = new Nickel();
                MyChange.Add(nickel);
            }

            for (int i = 0; i < 100; i++)
            {
                Coin penny = new Penny();
                MyChange.Add(penny);
            }
        }
예제 #4
0
 //Coins
 public void StockPennyInMachine(int amount)
 {
     Penny penny = new Penny();
     for(int i = 0; i <= amount; i++)
     {
         register.Add(penny);
     }      
 }
예제 #5
0
        public void AddPennyToWallet(int amount)
        {
            Penny penny = new Penny();

            for (int i = 0; i <= amount; i++)
            {
                coins.Add(penny);
            }
        }
예제 #6
0
        // constructor
        public Wallet()
        {
            coins = new List <Coin>();
            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickel  = new Nickel();
            Penny   penny   = new Penny();

            AddMoney(quarter, 12); // $3 in quarters
            AddMoney(dime, 10);    // $1 in dimes
            AddMoney(nickel, 15);  // $.75 in nickels;
            AddMoney(penny, 25);   // $.25 in pennies
            card = new Card();
        }