Exemplo n.º 1
0
 //constructor
 public SodaMachine()
 {
     inventory = new Inventory();
     inventory.AddGrapeToInventory(20);
     inventory.AddOrangeToInventory(20);
     inventory.AddLemonToInventory(20);
     cashbox = new CashBox();
     cashbox.AddQuarterToCashBox(20);
     cashbox.AddDimeToCashBox(10);
     cashbox.AddNickelToCashBox(20);
     cashbox.AddPennyToCashBox(50);
     enteredAmount = 0;
 }
Exemplo n.º 2
0
        //methods

        public bool EnterCoins()
        {
            Console.WriteLine("Enter a quarter, dime, nickel, penny or done:\n");
            string enteredCoin = Console.ReadLine();

            if (enteredCoin == "quarter")
            {
                cashbox.AddQuarterToCashBox(1);
                enteredAmount = (enteredAmount + Quarter.WORTH);
                Console.WriteLine("You have entered " + enteredAmount);
            }
            else if (enteredCoin == "dime")
            {
                cashbox.AddDimeToCashBox(1);
                enteredAmount = (enteredAmount + Dime.WORTH);
                Console.WriteLine("You have entered " + enteredAmount);
            }
            else if (enteredCoin == "nickel")
            {
                cashbox.AddNickelToCashBox(1);
                enteredAmount = (enteredAmount + Nickel.WORTH);
                Console.WriteLine("You have entered " + enteredAmount);
            }
            else if (enteredCoin == "penny")
            {
                cashbox.AddPennyToCashBox(1);
                enteredAmount = (enteredAmount + Penny.WORTH);
                Console.WriteLine("You have entered " + enteredAmount);
            }
            else if (enteredCoin == "done")
            {
                Console.WriteLine("You have entered " + enteredAmount);
                return(false);
            }
            return(true);
        }