private Pizza orderOneTypeOfPizza(Pizza pizza) { Console.WriteLine(); Console.WriteLine("Please type the name of the pizza."); string pizzaName = Console.ReadLine(); pizza = pizza.getPizza(pizzaName); while (pizza == null) { Console.WriteLine("Wrong pizza name. Type again."); pizzaName = Console.ReadLine(); pizza = new Pizza(); pizza = pizza.getPizza(pizzaName); } Console.WriteLine(); Console.WriteLine("What crust do you want?"); PizzaCrustFactory pizzaCrustFactory = new PizzaCrustFactory(); List <PizzaCrust> pizzaCrusts = pizzaCrustFactory.getAllPizzaCrusts(); foreach (var c in pizzaCrusts) { Console.WriteLine(c.type + " " + c.price + "$"); } string crustResponse = Console.ReadLine(); PizzaCrust crust = pizzaCrustFactory.setPizzaCrust(crustResponse); while (crust == null) { Console.WriteLine("Wrong pizza crust. Try again."); crustResponse = Console.ReadLine(); crust = pizzaCrustFactory.setPizzaCrust(crustResponse); } pizza.crust = crust; Console.WriteLine(); Console.WriteLine("How many " + pizzaName + " pizzas?"); string pizzaNumber = Console.ReadLine(); int number = getNumberOfItems(ref pizzaNumber); pizza.no = number; return(pizza); }
public PizzaCrust setPizzaCrust(string pizzaCrust) { PizzaCrust crust = null; if (pizzaCrust.ToLower().Equals("thin")) { crust = new Thin(); } else if (pizzaCrust.ToLower().Equals("classic")) { crust = new Classic(); } else if (pizzaCrust.ToLower().Equals("cheesy")) { crust = new Cheesy(); } return(crust); }
public Pizza(PizzaCrust crust, string name, double price) { this.crust = crust; this.name = name; this.price = price; }