/// <summary> /// Method to handle a coin being inserted into the machine. /// </summary> /// <param name="index"></param> public void CoinInserted(int index) { CoinArray[index].AddCoin(); //adds a coin to the appropriate coin object credit += CoinArray[index].Value; //adjusts the total credit the user has inserted so far AmtDisplay.DisplayAmount(credit); //updates the amount displayed on the machine UpdateLights(); //updates the lights and checks if anything has become purchaseable }
/// <summary> /// resets the machines data for when it is refilled /// </summary> /// <param name="canArr">the array of cans</param> /// <param name="coinArr">the array of coins</param> public void ResetData(Can[] canArr, Coin[] coinArr) { cans = canArr; coins = coinArr; _totalEntered = 0; amountD.DisplayAmount(_totalEntered); LightUpCans(); }
public void UpdateAmount(int value) { amount += value; amountDisplay.DisplayAmount(amount); foreach (Can can in cans) { can.UpdatePurchasableLight(amount); } }
/// <summary> /// Carries out process for when coin has been added including incrementing coins, updating amount, and turning on purchase lights. /// </summary> /// <param name="index">Index to indicate which type of coin has been inserted.</param> public void CoinInserted(int index) { moneyInserted += coins[index].AddCoin(); amountDisplay.DisplayAmount(moneyInserted); foreach (Drink d in drinks) { d.TurnOnPurchaseLight(moneyInserted); } }
public void insertCoin(int money) { totalInsertMoney += money; amountDisplay.DisplayAmount(totalInsertMoney); for (int i = 0; i < canList.Count; ++i) { canList[i].checkPurchasableLight(totalInsertMoney); } }
public void coinInserted() { foreach (Coin c in coins) { amtDisplay.DisplayAmount(amtInserted); foreach (Can can in cans) { can.checkIfCanPurchase(amtInserted); } } }
private void UpdateDisplays() { amountDisplay.DisplayAmount(Coin.TotalCoinsInserted); for (int i = 0; i < products.Length; i++) { products[i].UpdateLights(); } }
private void updateDebugDisplays() { // You need to change XXX to appropriate "object.property" displayNum10Yen.Display(coins[3].NumCoins); displayNum50Yen.Display(coins[2].NumCoins); displayNum100Yen.Display(coins[1].NumCoins); displayNum500Yen.Display(coins[0].NumCoins); displayNumCans0.Display(cans[0].Stock); displayNumCans1.Display(cans[1].Stock); displayNumCans2.Display(cans[2].Stock); displayNumCans3.Display(cans[3].Stock); amountDisplay.DisplayAmount(customer.CurrentFunds); }
private void updateDebugDisplays() { // You need to change XXX to appropriate "object.property" displayNum10Yen.Display(_coins[3]._numberOfCoins); displayNum50Yen.Display(_coins[2]._numberOfCoins); displayNum100Yen.Display(_coins[1]._numberOfCoins); displayNum500Yen.Display(_coins[0]._numberOfCoins); displayNumCans0.Display(_cans[0]._stock); displayNumCans1.Display(_cans[1]._stock); displayNumCans2.Display(_cans[2]._stock); displayNumCans3.Display(_cans[3]._stock); amountDisplay.DisplayAmount(_economy._currentlyInserted); }
private void updateDebugDisplays() { displayNum10Yen.Display(yen10.Num); displayNum50Yen.Display(yen50.Num); displayNum100Yen.Display(yen100.Num); displayNum500Yen.Display(yen500.Num); displayNumCans0.Display(drink1.NumCans); displayNumCans1.Display(drink2.NumCans); displayNumCans2.Display(drink3.NumCans); displayNumCans3.Display(drink4.NumCans); int total = ((yen10.NumReturn * yen10.Value) + (yen50.NumReturn * yen50.Value) + (yen100.NumReturn * yen100.Value) + (yen500.NumReturn * yen500.Value)); amountDisplay.DisplayAmount(total); }
private void updateDebugDisplays() { // You need to change XXX to appropriate "object.property" displayNum10Yen.Display(userMoney[0].numberOfCoins); displayNum50Yen.Display(userMoney[1].numberOfCoins); displayNum100Yen.Display(userMoney[2].numberOfCoins); displayNum500Yen.Display(userMoney[3].numberOfCoins); displayNumCans0.Display(allProduct[0].Stock); displayNumCans1.Display(allProduct[1].Stock); displayNumCans2.Display(allProduct[2].Stock); displayNumCans3.Display(allProduct[3].Stock); amountDisplay.DisplayAmount(totalAmountInserted); }
private void btnReset_Click(object sender, EventArgs e) { // Write the body to reset the field values of entity objects foreach (Can c in cans) { c.inventory = 4; c.checkIfCanPurchase(0); //will reset purchasable lights and sold out lights } coin500.numCoins = NUMCOINS[3]; coin100.numCoins = NUMCOINS[2]; coin50.numCoins = NUMCOINS[1]; coin10.numCoins = NUMCOINS[0]; vmController.amtInserted = 0; amountDisplay.DisplayAmount(vmController.amtInserted); updateDebugDisplays(); }