private static double CreateToppingAndCalculateCalories(List <Topping> toppings, double calories, Pizza pizza, string[] toppingInput) { string toppingName = toppingInput[1].ToLower(); double toppingWeight = double.Parse(toppingInput[2]); Topping topping = new Topping(toppingName, toppingWeight); calories += topping.CalculateCalories(); toppings.Add(topping); pizza.AddToppings(topping); return(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."); }
public static void Main(string[] args) { try { string[] pizzaProps = Console.ReadLine().Split(); string name = pizzaProps[1]; string[] doughProps = Console.ReadLine().Split(); string type = doughProps[1]; string tech = doughProps[2]; double grams = double.Parse(doughProps[3]); Dough dough = new Dough(type, tech, grams); Pizza pizza = new Pizza(name, dough); while (true) { string command = Console.ReadLine(); if (command == "END") { break; } string[] input = command.Split(); string typeTopping = input[1]; double gramsTopping = double.Parse(input[2]); Topping topping = new Topping(typeTopping, gramsTopping); pizza.Add(topping); } Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories."); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); return; } }
public void AddTopping(Topping topping) { this.toppings.Add(topping); }
public Pizza(string name, Dough dough, Topping topping) : this(name, dough) { this.Topping = topping; }