Esempio n. 1
0
    public static void Main()
    {
        try
        {
            var input = Console.ReadLine();

            while (input != "END")
            {
                var tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                switch (tokens[0])
                {
                case "Dough":
                    var dough = new Dough(tokens[1], tokens[2], double.Parse(tokens[3]));
                    Console.WriteLine($"{dough.GetFlourCalories():f2}");
                    break;

                case "Topping":
                    var topping = new Topping(tokens[1], double.Parse(tokens[2]));
                    Console.WriteLine($"{topping.GetToppingCalories():f2}");
                    break;

                case "Pizza":
                    MakePizza(tokens);
                    return;
                }

                input = Console.ReadLine();
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
Esempio n. 2
0
 public double GetTotalCalories()
 {
     return(Toppings.Sum(c => c.GetToppingCalories()) + Dough.GetFlourCalories());
 }