Example #1
0
 public void checkPurchasableLight(int totalInsertMoney)
 {
     if (totalInsertMoney >= price && count > 0)
     {
         purchasableLight.TurnOn();
     }
 }
Example #2
0
 /// <summary>
 /// Turns on purchase light based on the amount of money that has been inserted.
 /// </summary>
 /// <param name="inserted">Amount of money that has been inserted.</param>
 public void TurnOnPurchaseLight(int inserted)
 {
     if (inserted >= costOfDrink && !soldOutLight.IsOn())
     {
         purchasableLight.TurnOn();
     }
 }
Example #3
0
 public void UpdatePurchasableLight(int amount)
 {
     if ((amount >= price) && (numCans > 0))
     {
         purchasableLight.TurnOn();
     }
 }
Example #4
0
 public void flashSoldOut()
 {
     if (this.Stock <= 0)
     {
         soldOutLight.TurnOn();
     }
 }
Example #5
0
 /// <summary>
 /// Dispenses a can, decreases the number of cans, and turns on soldOutLights accordingly
 /// </summary>
 public void DispenseCan()
 {
     canDispenser.Actuate();
     numberOfDrinks--;
     if (numberOfDrinks == 0)
     {
         soldOutLight.TurnOn();
     }
 }
Example #6
0
 /// <summary>
 /// reduces the number of cans
 /// </summary>
 public int ReduceCan()
 {
     amount--;
     if (amount <= 0)
     {
         soldOutLt.TurnOn();
     }
     canD.Actuate();
     return(price);
 }
Example #7
0
 /// <summary>
 /// Turns on and off purchasable lights
 /// </summary>
 /// <param name="money">the money in the machine</param>
 public void PurLights(int money)
 {
     if (price <= money && amount > 0)
     {
         purchaseLt.TurnOn();
     }
     else
     {
         purchaseLt.TurnOff();
     }
 }
Example #8
0
 public void canPurchaseItem()
 {
     if (VendingMachine.totalAmountInserted >= this.Price && this.Stock > 0)
     {
         purchaseLight.TurnOn();
     }
     else
     {
         purchaseLight.TurnOff();
     }
 }
Example #9
0
 /// <summary>
 /// method to update all the lights associated with beverages. Will check if can is sold out,or if it is affordable.
 /// </summary>
 /// <param name="credit"></param>
 public void UpdateLights(int credit)
 {
     if (quantityAvailable == 0)
     {
         SoldOutLight.TurnOn(); purchaseableLight.TurnOff(); return;
     }
     if (credit >= price)
     {
         purchaseableLight.TurnOn(); return;
     }
     purchaseableLight.TurnOff();
 }
Example #10
0
 /// <summary>
 /// This is to check and make sure that the customer has enough money to purchase the can.
 /// </summary>
 /// <param name="amount"></param>
 /// <returns></returns>
 public bool CheckPurchasability(int amount)
 {
     if (amount >= price && count != 0)
     {
         purchaseableLight.TurnOn();
         return(true);
     }
     else
     {
         purchaseableLight.TurnOff();
         return(false);
     }
 }
Example #11
0
 public void Purchase()
 {
     if (purchasableLight.IsOn())
     {
         if (controller.TryToReturnChange(this.price))
         {
             canDispenser.Actuate();
             numCans--;
             if (numCans == 0)
             {
                 soldoutLight.TurnOn();
             }
         }
     }
 }
Example #12
0
 public void pushPurchaseButton()
 {
     if (vm.getTotalInsertMoney() >= price && count > 0)
     {
         vm.turnOffPurchaseableLight();
         if (vm.checkIfReturnChange(price))
         {
             count--;
             canDispenser.Actuate();
             if (count == 0)
             {
                 soldOutLight.TurnOn();
             }
             vm.coinDispense();
         }
     }
 }
Example #13
0
        /*public void Purchase()
         * {
         *  if(purchasableLight.IsOn() && !soldOutLight.IsOn())
         *  {
         *      if(Coin.GetChange())
         *      {
         *          canDispense.Actuate();
         *          this.Stock = this.stock - 1;
         *          Coin.TotalCoinsInserted -= this.price;
         *          cr.ButtonPressed();
         *      }
         *      else
         *      {
         *          vm.no
         *      }
         *  }
         * }*/

        public void UpdateLights()
        {
            if (Coin.TotalCoinsInserted >= this.price)
            {
                purchasableLight.TurnOn();
            }
            else
            {
                purchasableLight.TurnOff();
            }
            if (this.stock <= 0)
            {
                soldOutLight.TurnOn();
                purchasableLight.TurnOff();
            }
            else
            {
                soldOutLight.TurnOff();
            }
        }
Example #14
0
        /// <summary>
        /// This handles when a can is bought. It removes the can from the count, actuates the dispenser, and then changes the distplay
        /// </summary>
        /// <param name="totalValue">This is the total amount of money the customer has put into the machine</param>
        /// <returns>Returns an int with the price of the can </returns>
        public void CanBought(int totalValue)
        {
            if (count == 0)
            {
                return;
            }
            bool haveEnough = CheckPurchasability(totalValue);

            if (haveEnough != true)
            {
                return;
            }
            count--;
            dispenser.Actuate();
            if (count == 0)
            {
                soldOutLight.TurnOn();
                purchaseableLight.TurnOff();
            }
        }