/// <summary> /// This function returns Sandwich that is added in the order /// if any Sandwich item is not added properly by user ,this function will return null /// </summary> /// <returns>object for Sandwich class</returns> private Sandwich AddSandwich() { try { sandwichObj = new Sandwich(); Console.Clear(); Console.WriteLine("\nPlease Select Sandwich Type"); Console.WriteLine("1 for Signature Sandwich\n2 for Custom Sandwich"); Console.WriteLine("press any other key to cancel"); string input = Console.ReadLine(); if (string.Equals(input, "1")) { sandwichObj = CreateSignatureSandwich(); } else if (string.Equals(input, "2")) { sandwichObj = CreateCustomSandwich(); } else { return(null); } return(sandwichObj); } catch { return(null); } }
/// <summary> /// This function creates Signature sandwich and returns it /// </summary> /// <returns></returns> private Sandwich CreateSignatureSandwich() { try { sandwichObj = new Sandwich(); int input = 0; Console.Clear(); Console.WriteLine("\nPlease Select Signature Sandwich Type"); foreach (Sandwich sndwich in signatureSandwichesList) { int index = signatureSandwichesList.IndexOf(sndwich); Console.WriteLine("{0} for {1}", index + 1, sndwich.getName()); } Console.WriteLine("\npress any other key to cancel"); input = int.Parse(Console.ReadLine()); if (input <= 0 || input > signatureSandwichesList.Count) { return(null); } return(signatureSandwichesList[input - 1]); } catch { return(null); } }
/// <summary> /// This function is called inside the constructor of class SandwichOrderingSystem. /// It will create set of Signature Sandwiches which will be then displayed for user. /// </summary> /// <returns></returns> private void CreateSignatureSandwiches() { try { string name; string bread; string filling; string description; double price; List <string> optional = new List <string>(); Sandwich sandwich; // creating signature sandwich2 name = "Vegetarian Sandwich"; bread = breadList[3]; filling = fillingList[5]; description = "Oven roasted tomato, avocado, red bell pepper, red onion, mozzarella, ranch dressing"; price = basicSandwichPrice; optional.Add(optionalsList[2]); optional.Add(optionalsList[7]); optional.Add(optionalsList[9]); optional.Add(optionalsList[10]); sandwich = new Sandwich(name, bread, filling, optionalsList, description, price); signatureSandwichesList.Add(sandwich); // creating signature sandwich1 name = "Chicken Pesto Sandwich"; bread = breadList[2]; filling = fillingList[3]; description = "Oven roasted chicken breast, fresh mozzarella, basil pesto mayonnaise."; price = basicSandwichPrice + 1; optional.Add(optionalsList[0]); optional.Add(optionalsList[2]); optional.Add(optionalsList[4]); sandwich = new Sandwich(name, bread, filling, optionalsList, description, price); signatureSandwichesList.Add(sandwich); // creating signature sandwich3 name = "Margherita Chicken Sandwich"; bread = breadList[0]; filling = fillingList[3]; description = "Oven roasted chicken breast, fresh basil, sun dried tomato, provolone cheese, basil pesto mayonnaise"; price = basicSandwichPrice + 2; optional.Add(optionalsList[5]); optional.Add(optionalsList[11]); optional.Add(optionalsList[3]); optional.Add(optionalsList[4]); sandwich = new Sandwich(name, bread, filling, optionalsList, description, price); signatureSandwichesList.Add(sandwich); } catch (Exception e) { signatureSandwichesList.Clear(); Console.WriteLine("Exception occurred in createSignatureSandwiches : {0}", e.ToString()); } }
/// <summary> /// This function returns Combo that is added in the order /// if any combo item is not added properly by user ,this function will return null /// </summary> /// <returns>object for Combo class</returns> private Combo AddCombo() { try { comboObj = new Combo(); Sandwich sandwichObj; Drink drinkObj; Chips chipsObj; Console.Clear(); //Adding Sandwich to Combo sandwichObj = AddSandwich(); if (sandwichObj == null) { return(null); } else { comboObj.setSandwich(sandwichObj); } //Adding Drink to Combo drinkObj = AddDrink(); if (drinkObj == null) { return(null); } else { comboObj.setDrink(drinkObj); } //Adding Chips to Combo chipsObj = AddChips(); if (chipsObj == null) { return(null); } else { comboObj.setChips(chipsObj); } comboObj.setPrice(CalculateComboPrice(comboObj)); return(comboObj); } catch { return(null); } }
public void setSandwich(Sandwich sandwich) { this.sandwich = sandwich; }
public Combo() { sandwich = new Sandwich(); drink = new Drink(); chips = new Chips(); }
/// <summary> /// This function creates Custom sandwich and returns it /// </summary> /// <returns></returns> private Sandwich CreateCustomSandwich() { try { sandwichObj = new Sandwich(); int input = 0; Console.Clear(); //adding bread Console.WriteLine("\nPlease Select your custom sandwich options\nselect your bread"); foreach (string breadtype in breadList) { int index = breadList.IndexOf(breadtype); Console.WriteLine("{0} for {1}", index + 1, breadtype); } input = int.Parse(Console.ReadLine()); if (input <= 0 || input > breadList.Count) { return(null); } sandwichObj.setBread(breadList[input - 1]); //adding mainfilling Console.WriteLine("\nPlease select your filling"); foreach (string filltype in fillingList) { Console.WriteLine("{0} for {1}", fillingList.IndexOf(filltype) + 1, filltype); } input = int.Parse(Console.ReadLine()); if (input <= 0 || input > fillingList.Count) { return(null); } sandwichObj.setFilling(fillingList[input - 1]); //adding optionals Console.WriteLine("\nPlease select your optionals"); foreach (string optionalstype in optionalsList) { Console.WriteLine("{0} for {1}", optionalsList.IndexOf(optionalstype) + 1, optionalstype); } Console.WriteLine("\nType multiple optionals by separating them with ',' eg. 1,2,3"); string[] optionalsinput = Console.ReadLine().Split(','); foreach (string optional in optionalsinput) { input = int.Parse(optional); if (input <= 0 || input > optionalsList.Count) { return(null); } sandwichObj.setOptionals(optionalsList[input - 1]); } sandwichObj.setName("Custom Sandwich"); sandwichObj.setDescription("Custom Sandwich"); sandwichObj.setPrice(basicSandwichPrice); return(sandwichObj); } catch { return(null); } }