Esempio n. 1
0
        private static void MakePizza(string[] args)
        {
            var toppingsCount = int.Parse(args[2]);
            var pizza         = new Pizza(args[1], toppingsCount);
            var doughArgs     = Console.ReadLine().Split(' ');
            var dough         = new Dough(doughArgs[1], doughArgs[2], double.Parse(doughArgs[3]));

            pizza.AddDough(dough);

            for (int i = 0; i < toppingsCount; i++)
            {
                var toppingArgs = Console.ReadLine().Split(' ');
                var topping     = new Topping(toppingArgs[1], double.Parse(toppingArgs[2]));
                pizza.AddToppings(topping);
            }

            Console.WriteLine($"{pizza.Name} - {pizza.CalculateTotalCalories():f2} Calories.");
        }
Esempio n. 2
0
        public static void MakePizza(string[] tokens)
        {
            var numberToppings = int.Parse(tokens[2]);
            var pizza          = new Pizza(tokens[1], numberToppings);

            // Dough
            var doughInfo = Console.ReadLine().Split(' ');
            var dough     = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3]));

            pizza.Dough = dough;

            // Toppings
            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.");
        }
Esempio n. 3
0
        public static void Main()
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (input == "END")
                {
                    break;
                }

                var tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    switch (tokens[0])
                    {
                    case "Dough":
                        var dough = new Dough(tokens[1], tokens[2], double.Parse(tokens[3]));
                        Console.WriteLine($"{dough.GetCalories():f2}");
                        break;

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

                    case "Pizza":
                        MakePizza(tokens);
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return;
                }
            }
        }
Esempio n. 4
0
        public static void Main()
        {
            string input;

            try
            {
                while ((input = Console.ReadLine()) != "END")
                {
                    var args = input.Split(' ');

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

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

                    case "Pizza":
                        MakePizza(args);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }