Beispiel #1
0
        static void Main(string[] args)
        {
            var pizzaInput = Console.ReadLine().Split(" ");
            var doughInput = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

            try
            {
                var testPizza = new Pizza(pizzaInput[1], new Dough(doughInput[1], doughInput[2], double.Parse(doughInput[3])));
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                System.Environment.Exit(0);
            }


            var thePizza = new Pizza(pizzaInput[1], new Dough(doughInput[1], doughInput[2], double.Parse(doughInput[3])));

            while (true)
            {
                var command = Console.ReadLine();

                if (command == "END")
                {
                    break;
                }

                var toppingInput  = command.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                var toppingType   = toppingInput[1];
                var toppingWeight = double.Parse(toppingInput[2]);

                try
                {
                    var testTopping = new Topping(toppingType, toppingWeight);
                    thePizza.AddTopping(testTopping);
                }
                catch (ArgumentException ex)
                {
                    if (toppingWeight < 1 || toppingWeight > 50)
                    {
                        Console.WriteLine(toppingType + ex.Message);
                    }
                    else
                    {
                        Console.WriteLine(ex.Message);
                    }
                    System.Environment.Exit(0);
                }
            }

            Console.WriteLine(thePizza);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            string[] pizzaInput = Console.ReadLine().Split();
            string   pizzaName  = pizzaInput[1];

            string[] doughInput      = Console.ReadLine().Split();
            string   flourType       = doughInput[1];
            string   bakingTechinque = doughInput[2];
            int      doughWeight     = int.Parse(doughInput[3]);

            Pizza pizza;

            try
            {
                pizza = new Pizza(pizzaName);
                Dough dough = new Dough(flourType, bakingTechinque, doughWeight);
                pizza.Dough = dough;

                string toppingInput;
                while ((toppingInput = Console.ReadLine()) != "END")
                {
                    string[] toppingSplit  = toppingInput.Split();
                    string   toppingType   = toppingSplit[1];
                    int      toppingWeight = int.Parse(toppingSplit[2]);

                    Topping currentTopping = new Topping(toppingType, toppingWeight);
                    pizza.AddToppig(currentTopping);
                }

                Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():F2} Calories.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }
        }