public static void returnAllChange() { Coin.returnChange(VendingMachine.totalAmountInserted); totalAmountInserted = 0; for (int i = 0; i < 4; i++) { allProduct[i].canPurchaseItem(); } }
public static void purchaseItem(Can product) { bool changeAvaliable = false; if (product.Stock > 0) { if (totalAmountInserted >= product.Price) { changeAvaliable = Coin.returnChange(totalAmountInserted - product.Price); if (changeAvaliable) { product.Stock--; if (product.Stock <= 0) { product.flashSoldOut(); } product.dispenseCan(); totalAmountInserted = 0; for (int i = 0; i < 4; i++) { allProduct[i].canPurchaseItem(); } } else { noChangeLight.TurnOn3Sec(); } } } }