Beispiel #1
0
        public static void Main()
        {
            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                string[] inParams = input.Split(' ');

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

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

                    case "Pizza":
                        MakePizza(inParams);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return;
                }
            }
        }
Beispiel #2
0
    public static void Main()
    {
        var info = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

        try
        {
            while (info[0] != "END")
            {
                switch (info[0].ToLower())
                {
                case "pizza":
                    PrintPizza(info[1], int.Parse(info[2]));
                    break;

                case "dough":
                    var dough = new Dough()
                    {
                        DoughType       = info[1],
                        BakingTechnique = info[2],
                        Weight          = double.Parse(info[3])
                    };
                    Console.WriteLine($"{dough.Calories():f2}");
                    break;

                case "topping":
                    var topping = new Topping()
                    {
                        Type   = info[1],
                        Weight = double.Parse(info[2])
                    };
                    Console.WriteLine($"{topping.Calories():f2}");
                    break;
                }
                info = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }