Ejemplo n.º 1
0
        private static Queue <string> PrintDoughCalories(Queue <string> commands)
        {
            string command = commands.Dequeue();

            string[] inputArgs       = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string   flourType       = inputArgs[1];
            string   bakingTechnique = inputArgs[2];
            double   doughWeight     = double.Parse(inputArgs[3]);
            Dough    dough           = new Dough(flourType, bakingTechnique, doughWeight);

            Console.WriteLine($"{dough.CalculateCalories():f2}");
            return(commands);
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            var input = Console.ReadLine();

            try
            {
                while (input != "END")
                {
                    var tokens = input.Split();

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

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

                    case "pizza":
                        MakePizza(tokens);
                        break;
                    }
                    input = Console.ReadLine();
                }
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }