void UpdateDisplay() { displayList.Clear(); lbBasket.Items.Clear(); lblScreen.Text = selfCheckout.GetPromptForUser(); List <Product> temp = scannedProducts.GetProducts(); for (int i = 0; i < temp.Count; i++) { if (displayList.Count != 0) { for (int j = 0; j < displayList.Count; j++) { if (displayList[j].GetName() == temp[i].GetName()) { displayList[j].AddExistingItem(temp[i].CalculatePrice()); break; } if (displayList.Count - 1 == j) { DisplayList s = new DisplayList(temp[i].GetName(), temp[i].CalculatePrice(), temp[i].GetWeight()); displayList.Add(s); break; } } } else { DisplayList s = new DisplayList(temp[i].GetName(), temp[i].CalculatePrice(), temp[i].GetWeight()); displayList.Add(s); } } displayList.ForEach(i => lbBasket.Items.Add(("£" + (i.GetPrice() * 0.01f).ToString("0.00") + "|" + i.GetName() + "|x" + i.GetQuantity()))); lblTotalPrice.Text = "£" + (scannedProducts.CalculatePrice() * 0.01f).ToString("0.00"); lblBaggingAreaExpectedWeight.Text = baggingAreaScale.GetExpectedWeight(displayList).ToString("n2"); lblBaggingAreaCurrentWeight.Text = baggingAreaScale.GetCurrentWeight().ToString("n2"); btnUserScansBarcodeProduct.Enabled = (baggingAreaScale.IsWeightOk() && selfCheckout.GetCurrentProduct() == null); btnUserSelectsLooseProduct.Enabled = (baggingAreaScale.IsWeightOk() && selfCheckout.GetCurrentProduct() == null); btnUserWeighsLooseProduct.Enabled = looseItemScale.IsEnabled(); btnUserPutsProductInBaggingAreaCorrect.Enabled = (!looseItemScale.IsEnabled() && !(selfCheckout.GetCurrentProduct() == null)); btnUserPutsProductInBaggingAreaIncorrect.Enabled = (!looseItemScale.IsEnabled() && !(selfCheckout.GetCurrentProduct() == null)); btnUserChooseToPay.Enabled = (baggingAreaScale.IsWeightOk() && scannedProducts.HasItems() && selfCheckout.GetCurrentProduct() == null); btnRemoveProduct.Enabled = (baggingAreaScale.IsWeightOk() && scannedProducts.HasItems() && selfCheckout.GetCurrentProduct() == null && !scannedProducts.RemoveRequestAccepted()); btnAdminOverridesWeight.Enabled = (!baggingAreaScale.IsWeightOk() && scannedProducts.HasItems() && selfCheckout.GetCurrentProduct() == null) && !scannedProducts.RemoveRequestAccepted(); btnConfirmRemove.Enabled = scannedProducts.RemoveRequestAccepted(); }
public string GetPromptForUser() //Done in order so it doesn't overwrite the message { if (scannedProducts.HasItems() && baggingArea.IsWeightOk() && currentProduct == null) { return("Scan another item or pay"); } if (baggingArea.IsWeightOk() && currentProduct == null) { return("Scan Loose or Packaged Product"); } if (looseItemScale.IsEnabled()) { return("Place item on scale"); } if (currentProduct != null && looseItemScale.IsEnabled() == false) { return("Place the item in the bagging area"); } if (scannedProducts.HasItems() && baggingArea.IsWeightOk() == false) { return("Weight incorrect, needs admin override"); } return("ERROR: Unknown state!"); //Defaults to error }
public string GetPromptForUser() { if ((scannedProducts.HasItems() && baggingArea.IsWeightOk()) && (currentProduct == null)) { return("Scan an item or pay."); } if (baggingArea.IsWeightOk() && (currentProduct == null)) { return("Scan an item."); } if (looseItemScale.IsEnabled()) { return("Place item on scale."); } if ((currentProduct != null) && !looseItemScale.IsEnabled()) { return("Place the item in the bagging area."); } if (!scannedProducts.HasItems() || baggingArea.IsWeightOk()) { return("ERROR: UNKNWON STATE"); } return("Please wait, assistant is on the way."); }