static void Main(string[] args) { string pizzaName = Console.ReadLine().Split()[1]; string[] doughtInfo = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); Dough dought = new Dough(doughtInfo[1], doughtInfo[2], double.Parse(doughtInfo[3])); Pizza pizza = new Pizza(pizzaName, dought); string input = Console.ReadLine(); while (input != "END") { string[] toppingInfo = input .Split(" ", StringSplitOptions.RemoveEmptyEntries); Topping topping = new Topping(toppingInfo[1], double.Parse(toppingInfo[2])); pizza.AddTopping(topping); input = Console.ReadLine(); } Console.WriteLine($"{pizzaName} - {pizza.GetCalories():F2} Calories."); }
public static void MakePizza(string[] tokens) { var numberToppings = int.Parse(tokens[2]); var pizza = new Pizza(tokens[1], numberToppings); var doughInfo = Console.ReadLine().Split(' '); var dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3])); pizza.Dough = dough; for (var i = 0; i < numberToppings; i++) { var topInfo = Console.ReadLine().Split(' '); var topping = new Topping(topInfo[1], double.Parse(topInfo[2])); pizza.AddTopping(topping); } Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories."); }