public void checkPurchasableLight(int totalInsertMoney) { if (totalInsertMoney >= price && count > 0) { purchasableLight.TurnOn(); } }
/// <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(); } }
public void UpdatePurchasableLight(int amount) { if ((amount >= price) && (numCans > 0)) { purchasableLight.TurnOn(); } }
public void flashSoldOut() { if (this.Stock <= 0) { soldOutLight.TurnOn(); } }
/// <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(); } }
/// <summary> /// reduces the number of cans /// </summary> public int ReduceCan() { amount--; if (amount <= 0) { soldOutLt.TurnOn(); } canD.Actuate(); return(price); }
/// <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(); } }
public void canPurchaseItem() { if (VendingMachine.totalAmountInserted >= this.Price && this.Stock > 0) { purchaseLight.TurnOn(); } else { purchaseLight.TurnOff(); } }
/// <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(); }
/// <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); } }
public void Purchase() { if (purchasableLight.IsOn()) { if (controller.TryToReturnChange(this.price)) { canDispenser.Actuate(); numCans--; if (numCans == 0) { soldoutLight.TurnOn(); } } } }
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(); } } }
/*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(); } }
/// <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(); } }