// private static void PrintToppingList() // { // int index = 0; // UserInterface.MenuTitle("Available Toppings: "); // // foreach (Topping topping in _toppingSingleton.Toppings) // { // index++; // sc.WriteLine($"{index} {topping.Name}"); // } // sc.WriteLine(); // } private static APizza AddATopping(APizza currentPizza) { bool validEntry = false; int toppingNumber = -1; Topping newTopping = new Topping(); while (!validEntry) { // int count = _toppingSingleton.Toppings.Count; toppingNumber = UserInterface.Selector("Select a topping to add: ", _toppingSingleton.ToStringList()); newTopping = _toppingSingleton.Toppings[toppingNumber]; foreach (Topping topping in currentPizza.Toppings) { if (topping.Name == newTopping.Name) { sc.ForegroundColor = ConsoleColor.Red; sc.WriteLine("You already have " + topping.Name + " on your pizza."); sc.WriteLine("Please make another selection");; sc.ResetColor(); validEntry = false; } else { validEntry = true; } } } currentPizza.Toppings.Add(newTopping); return(currentPizza); }
public Pizza Map(APizza model) { PIZZA_TYPE pizzaType; switch (model) { case MeatPizza: pizzaType = PIZZA_TYPE.Meat; break; case VeganPizza: pizzaType = PIZZA_TYPE.Vegan; break; case CustomPizza: pizzaType = PIZZA_TYPE.Custom; break; default: throw new ArgumentException("PizzaMapper encountered unknown type when mapping from Domain Model to DB Model"); } Pizza pizza = new Pizza(); pizza.PizzaType = pizzaType; pizza.Crust = crustMapper.Map(model.Crust); pizza.Size = sizeMapper.Map(model.Size); List <Entities.Topping> toppings = new List <Entities.Topping>(); model.Toppings.ForEach(topping => toppings.Add(toppingMapper.Map(topping))); pizza.Toppings = toppings; pizza.Price = model.Price; return(pizza); }
public APizza CustomizePizza(APizza pizza) { bool loop = true; while (loop) { Console.WriteLine("your current pizza is: "); Console.WriteLine(pizza); PrintPizzaCustomizeMenu(); var actionChoice = ReadIntInput(0, 3); switch (actionChoice) { case 1: pizza = CustomizeTopping(pizza); break; case 2: pizza = ChangeCrust(pizza); break; case 3: pizza = ChangeSize(pizza); break; case 0: loop = false; break; default: break; } } return(pizza); }
public APizza AddDefaultPizza() { // DefaultPizza one = new DefaultPizza(); APizza one = pizzaFactory.Create <DefaultPizza>(); return(one); }
public void Test_Pizza_Headings() { // var sut = new CustomPizza(); var actual = APizza.Headings(); Assert.IsType <string>(actual); }
public BYOPizzaMenu(AOrder order, APizza pizza) { currentOrder = order; customPizza = pizza; SetOptions(); OptionRange[1] = MenuOptions.Count; }
private static void addTopping(ref APizza pizza, string str) { if (pizza.Toppings.Count >= 5 || str.Equals("No")) { return; } pizza.Toppings.Add(getItem(_toppingSingleton.Toppings, "Please select a topping")); if (pizza.Toppings.Count < 2) { addTopping(ref pizza, "Yes"); } else { var temp = getItem(new List <string> { "Yes", "No" }, "Add another topping?"); Console.WriteLine(temp); if (temp == "Yes") { addTopping(ref pizza, "Yes"); } else if (temp == "No") { addTopping(ref pizza, "No"); } else { Console.WriteLine("Invalid input"); } } }
/* #endregion */ /* #region Customize Toppings */ public APizza CustomizeTopping(APizza pizza) { bool loop = true; while (loop) { var toppings = GetAllToppings(); PrintPizza(pizza); PrintToppingMenu(); var toppingAction = ReadIntInput(0, 2); switch (toppingAction) { case 1: AddTopping(pizza); break; case 2: RemoveTopping(pizza); break; case 0: loop = false; break; } //todo: allow user to exit if (!pizza.IsPizzaToppingsOk()) { loop = true; } } return(pizza); }
public override APizza CreatePizza(PizzaType type) { APizza pizza = null; switch (type) { case PizzaType.Cheese: pizza = new CaliforniaStyleCheesePizza(); break; case PizzaType.Pepperoni: pizza = new CaliforniaStylePepperoniPizza(); break; case PizzaType.Clam: pizza = new CaliforniaStyleClamPizza(); break; case PizzaType.Veggie: pizza = new CaliforniaStyleVeggiePizza(); break; default: pizza = new CaliforniaStyleCheesePizza(); break; } return(pizza); }
public APizza AddPizza() { // default pizza // custom pizza APizza newPizza = null; Console.WriteLine("Deal - Large Pepperoni, Green Pepper for only $6.99 + $0.01\n"); Console.WriteLine("[0] Large Hand Tossed Pepperoni, Green Pepper\n[1] Build your own.\n[2] Cancel Order."); int select; string inputStr = Console.ReadLine(); if (int.TryParse(inputStr, out select)) { if (select == 0) { newPizza = AddDefaultPizza(); } else if (select == 1) { newPizza = AddCustomPizza(); } else if (select != 2) { Console.WriteLine("Please try again.\n"); newPizza = AddPizza(); } } else { Console.WriteLine("Please try again.\n"); newPizza = AddPizza(); } return(newPizza); }
public void TestBuildingPizza() { APizza expected = new APizza(); APizza actual = Factory.CreateAPizza(); Assert.True(expected.Equals(actual)); }
public AddPizzaItemMenu(AOrder order, APizza customPizza, int menu) { currentOrder = order; SubMenuType = menu; CustomPizza = customPizza; SetOptions(); OptionRange[1] = MenuOptions.Count; }
public int AddPizza(APizza pizza) { var mappedPizza = mapper.Map(pizza); context.Add(mappedPizza); context.SaveChanges(); return(mappedPizza.PizzaId); }
/// <summary> /// /// </summary> /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body"> (optional)</param> /// <returns>ApiResponse of Object(void)</returns> public ApiResponse <Object> ApiPizzaPostWithHttpInfo(APizza body = null) { var localVarPath = "/api/Pizza"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json-patch+json", "application/json", "text/json", "application/_*+json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ApiPizzaPost", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <Object>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), null)); }
private static APizza SelectSize(APizza currentPizza) { string input = System.Console.ReadLine(); int index = int.Parse(input); Size size = _sizeSingleton.Sizes[index - 1]; currentPizza.Size = size; return(currentPizza); }
public void Test_PizzaContentstype(APizza pizza) { Assert.IsType <string>(pizza.Name); Assert.IsType <Size>(pizza.Size); Assert.IsType <double>(pizza.Size.Price); Assert.IsType <List <Topping> >(pizza.Toppings); Assert.IsType <Crust>(pizza.Crust); Assert.IsType <string>(pizza.Name); }
public override void Handle(Context context) { currentPizza = context.Order.Pizzas[context.Order.Pizzas.Count - 1]; SelectSize(context); SelectCrust(context); AddToppings(context); context.State = StateSingleton.Instance.GetState <CheckOrderTotalState>(); }
private static void ShowCurrentOrder(List <APizza> pizzas) { sc.WriteLine("Current Order: "); APizza.Headings(); foreach (APizza p in pizzas) { sc.WriteLine(p.ToString()); } }
public CustomPizza AddCustomPizza() { // CustomPizza thePizza = new CustomPizza(); APizza thePizzaProduct = pizzaFactory.Create <CustomPizza>(); CustomPizza thePizza = (CustomPizza)thePizzaProduct; thePizza.BuildPizza(); return(thePizza); }
private void AddToOrder(APizza aPizza, int size, int qty, float price) { OrderDetail cd = new(); cd.ProductID = aPizza.ID; cd.ProductName = aPizza.Name; cd.Quantity = qty; cd.Price = price; newOrderDetails.Add(cd); }
private static void ShowAllPizzas(List <APizza> pizzas) { int index = 1; APizza.Headings(); foreach (APizza p in pizzas) { sc.WriteLine(index + ". " + p.ToString()); } }
private static APizza RemoveATopping(APizza currentPizza) { int toppingNumber = UserInterface.Selector("Which topping would you like to remove", currentPizza.ToppingStrings()); currentPizza.Toppings.RemoveAt(toppingNumber); sc.WriteLine("After topping removal: " + currentPizza.ToString()); return(currentPizza); }
private static void PrintCurrentToppingsList(APizza Pizza) { var index = -1; foreach (var item in Pizza.Toppings) { Console.WriteLine($"{index += 1}{"-"} {item.ToFormat()}"); } Console.WriteLine($"{index += 1}{"-"} {"Exit"}"); }
void Options(APizza cPizza) { System.Console.WriteLine(); Console.WriteLine("Choose a Crust: "); Console.WriteLine("1: Thick ------- $ 1.00 "); Console.WriteLine("2: Thin ------- $ 1.00 "); int c = Convert.ToInt32(Console.ReadLine()); switch (c) { case 1: cPizza.Crust.Name = crusts[0].Name; cPizza.Crust.Price = crusts[0].Price; break; case 2: cPizza.Crust.Name = crusts[1].Name; cPizza.Crust.Price = crusts[1].Price; break; default: Console.WriteLine("Please Enter A valid Option"); break; } System.Console.WriteLine(); Console.WriteLine("Choose a Size: "); Console.WriteLine("1: Small -------- $ 9.00 "); Console.WriteLine("2: Medium ------- $ 12.00 "); Console.WriteLine("3: Large -------- $ 15.00 "); int s = Convert.ToInt32(Console.ReadLine()); switch (s) { case 1: cPizza.Size.Name = sizes[0].Name; cPizza.Size.Price = sizes[0].Price; break; case 2: cPizza.Size.Name = sizes[1].Name; cPizza.Size.Price = sizes[1].Price; break; case 3: cPizza.Size.Name = sizes[2].Name; cPizza.Size.Price = sizes[2].Price; break; default: Console.WriteLine("Please Enter A valid Option"); break; } }
/// <summary> /// /// </summary> //will need to change this later private static void DisplayOrder(APizza pizza, string crust, string size, List <string> toppingList) { Console.WriteLine($"Your order is: {pizza}, {crust}, {size} with toppings: "); string[] toppingsArray = toppingList.ToArray(); foreach (var toppings in toppingList) { System.Console.WriteLine(toppings); } //find a way to store the object APizza type, check with if else method and return price }
public Pizza Map(APizza model, Entities.AnimalsDbContext context) { PIZZA_TYPE pizzaType; switch (model) { case MeatPizza: pizzaType = PIZZA_TYPE.Meat; break; case VeganPizza: pizzaType = PIZZA_TYPE.Vegan; break; case CustomPizza: pizzaType = PIZZA_TYPE.Custom; break; default: throw new ArgumentException("PizzaMapper encountered unknown type when mapping from Domain Model to DB Model"); } Pizza pizza = new Pizza(); pizza.PizzaType = pizzaType; pizza.Crust = crustMapper.Map(model.Crust, context); pizza.Size = sizeMapper.Map(model.Size, context); // need to group the PizzaToppings by their topping's toppingtype // need to make AMOUNT = Count of the grouping List <Entities.Topping> mappedToppings = new List <Entities.Topping>(); model.Toppings.ForEach(t => mappedToppings.Add(toppingMapper.Map(t, context))); var grouped = mappedToppings.GroupBy(t => t.ToppingType); foreach (var group in mappedToppings.GroupBy(t => t.ToppingType)) { var firstTopping = group.First(); if (firstTopping is null) { // Should never happen throw new ArgumentException("Everything is on fire. Just rewrite everything please"); } PizzaTopping pt = new PizzaTopping(); pt.Pizza = pizza; pt.Topping = firstTopping; pt.Amount = group.Count(); firstTopping.PizzaToppings.Add(pt); pizza.PizzaToppings.Add(pt); } pizza.Price = model.Price; return(pizza); }
public APizza OrderPizza(PizzaType type) { APizza pizza = CreatePizza(type); pizza.Prepare(); pizza.Bake(); pizza.Cut(); pizza.Box(); return(pizza); }
public void Test_PizzaContents(APizza pizza) { Assert.NotNull(pizza.Name); Assert.NotNull(pizza.Size); Assert.NotNull(pizza.Size.Price); Assert.NotNull(pizza.Toppings); Assert.NotNull(pizza.Crust); Assert.NotNull(pizza.Crust.Name); Assert.NotNull(pizza.Size); Assert.True(pizza.Toppings.Count >= 2); }
private static APizza MakePizza(ref APizza p) { p.Size = getItem(_sizeSingleton.Sizes, "Please select a size"); if (p.GetType().Equals(typeof(CustomPizza))) { p.Toppings = new List <Topping>(); p.Crust = getItem(_crustSingleton.Crusts, "Please select a crust"); addTopping(ref p, "Yes"); } return(p); }
public APizza OrderPizza(String type) { APizza pizza = factory.CreatePizza(type); pizza.Prepare(); pizza.Bake(); pizza.Cut(); pizza.Box(); return(pizza); }