static void Main(string[] args) { try { string[] pizzaArgs = Console.ReadLine() .Split(); string pizzaName = pizzaArgs[1]; string[] doughArgs = Console.ReadLine() .Split(); string doughFlourType = doughArgs[1]; string doughBackingTechnique = doughArgs[2]; double weight = double.Parse(doughArgs[3]); Dough dough = new Dough(doughFlourType, doughBackingTechnique, weight); Pizza pizza = new Pizza(pizzaName, dough); string inputLine = Console.ReadLine(); while (inputLine != "END") { string[] toppingArgs = inputLine .Split(); string toppingType = toppingArgs[1]; double weightTopping = double.Parse(toppingArgs[2]); Topping topping = new Topping(toppingType, weightTopping); pizza.AddTopping(topping); inputLine = Console.ReadLine(); } Console.WriteLine($"{pizza.Name} - {pizza.GetTotalCalories().ToString("f2")} Calories."); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { var pizza = Console.ReadLine().Split(" ").ToArray(); var doughInput = Console.ReadLine().Split(" ").ToArray(); var dough = new Dough(doughInput[1], doughInput[2], decimal.Parse(doughInput[3])); var myPizza = new Pizza(pizza[1], dough); var input = Console.ReadLine(); while (input != "END") { var currentInput = input.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); var topping = new Topping(currentInput[1], decimal.Parse(currentInput[2])); myPizza.Add(topping); input = Console.ReadLine(); } Console.WriteLine(myPizza); }
public Pizza(string name, Dough dough) { this.Name = name; this.dough = dough; this.toppings = new List <Topping>(); }