private void selection_made(object sender, SelectionEventArgs e) { if (this.paymentFacade.funds >= e.pCost) { productFacade.DispenseProduct(e.index); paymentFacade.storeCoins(); this.paymentFacade.funds = paymentFacade.deliverChange(e.pCost, paymentFacade.funds); } }
public void Button(Object sender, EventArgs e) { int idx = 0; //var product = sender; foreach (var prod in this.productList) { if (sender.Equals(prod)) { idx = Array.IndexOf(this.productList, prod); } } ProductKind product = this.productList[idx]; if (product.Cost <= this.payments.credit) { //when the Buton is selected //call Product Facade to dispense the product products.DispenseProduct(product); payments.DispenseChange(product.Cost); } }