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

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

                var item = tokens[0];

                if (item == "Pizza")
                {
                    var pizzaName = tokens[1];

                    pizza = new Pizza(pizzaName);
                }
                else if (item == "Dough")
                {
                    var flourType  = tokens[1];
                    var bakingTech = tokens[2];
                    var weight     = decimal.Parse(tokens[3]);

                    var dough = new Dough(flourType, bakingTech, weight);

                    pizza.Dough = dough;
                }
                else if (item == "Topping")
                {
                    var toppingType = tokens[1];
                    var weight      = decimal.Parse(tokens[2]);

                    var topping = new Topping(toppingType, weight);

                    pizza.AddTopping(topping);
                }

                input = Console.ReadLine();
            }

            if (pizza != null)
            {
                Console.WriteLine(pizza);
            }
        }
        catch (ArgumentException ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
        public void TestAddPizza()
        {
            Orders OrderTest = new Orders();
            IPizza pizza1    = Pizza.OrderPizza(SizesEnum.MeduimSize);

            pizza1 = Pizza.AddCrust(pizza1, CrustsEnums.Thin);
            pizza1 = Pizza.AddTopping(pizza1, ToppingsEnums.Bacon);
            IPizza pizza2 = Pizza.OrderPizza(SizesEnum.MeduimSize);

            OrderTest.AddPizza(pizza1);
            OrderTest.AddPizza(pizza2);

            Assert.IsTrue(OrderTest.getPizzasInOrder().Count == 2);
        }
        public void TestRemovePizza()
        {
            Orders OrderTest = new Orders();
            IPizza pizza1    = Pizza.OrderPizza(SizesEnum.MeduimSize);

            pizza1 = Pizza.AddCrust(pizza1, CrustsEnums.Thin);
            pizza1 = Pizza.AddTopping(pizza1, ToppingsEnums.Bacon);
            IPizza pizza2 = Pizza.OrderPizza(SizesEnum.MeduimSize);

            OrderTest.AddPizza(pizza1);
            OrderTest.AddPizza(pizza2);
            OrderTest.RemovePizza(pizza1);
            Assert.AreEqual(OrderTest.getTotalPriceOrder(), 5.00M);
        }
Beispiel #4
0
        public void PizzaHasMaxFiveToppingsException()
        {
            //Given
            var pizza = new Pizza();
            //When
            List <Topping> toppingList = new List <Topping>
            {
                new Topping("Jalapenos"),
                new Topping("Green Peppers"),
                new Topping("Red Peppers"),
                new Topping("Mushrooms"),
                new Topping("Cheese")
            };

            pizza.AddTopping(toppingList);
            pizza.AddTopping(new Topping("Pineapple"));
            var actual   = pizza.Toppings.Count;
            var expected = 5;

            //Then
            Assert.NotNull(actual);
            Assert.True(actual == expected);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Pizza p1 = new Pizza(Size.Medium, Dough.GlutenFree, "cheese");
            Console.WriteLine(p1);

            p1.AddTopping("chili");
            Console.WriteLine(p1);

            p1.AddTopping("pepper flakes");
            Console.WriteLine(p1);

            p1.AddSide(Sides.Chips);
            p1.ChangeSize(Size.XLarge);
            p1.AddTopping("mushrooms");
            Console.WriteLine(p1);

            p1.AddSide(Sides.DippingSauce);
            p1.ChangeDough(Dough.Wholewheat);
            Console.WriteLine(p1);

            p1.RemoveSide(Sides.Chips);
            try
            {
                // try to remove a topping that was not there
                p1.RemoveTopping("pepper");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                //throw;
            }

            string filename = "pizza.txt";
            Console.WriteLine($"Saving the pizza to {filename}");
            File.WriteAllText(filename, p1.ToString());
            //File.WriteAllText(filename, new JavaScriptSerializer().Serialize(p1));
        }
Beispiel #6
0
        private static void AddToppings(Pizza pizza)
        {
            List <Topping> toppings = APizzaPartFactory.GetToppings();

            Console.WriteLine("Current toppings: ");
            foreach (var topping in pizza.Toppings)
            {
                Console.Write(topping + " ");
            }
            Console.WriteLine(); //Just to start a new line.
            while (pizza.Toppings.Count < 5)
            {
                for (var index = 0; index < toppings.Count(); index++)
                {
                    Console.WriteLine($"{index}: {toppings[index]} ${toppings[index].Price}");
                }
                Console.WriteLine("Input a number for a topping or any other number to quit.");
                bool validInput = int.TryParse(Console.ReadLine(), out int input);
                if (validInput)
                {
                    if (input > 0 && input < toppings.Count())
                    {
                        var  selectedTopping = APizzaPartFactory.MakeTopping(toppings[input].Name);
                        bool added           = pizza.AddTopping(selectedTopping);
                        if (added)
                        {
                            Console.WriteLine($"Added {selectedTopping}");
                            if (pizza.Toppings.Count() >= 5)
                            {
                                Console.WriteLine("You've reached your limit on toppings");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Unable to add topping.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Thank you for selecting your toppings.");
                        return;
                    }
                }
                else
                {
                    Console.WriteLine("Invalid input, try again.");
                }
            }
        }
    public static void Main()
    {
        string inputLine = Console.ReadLine();

        while (inputLine != "END")
        {
            string[] tokens      = inputLine.Split();
            string   productType = tokens[0];

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

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

                case "Pizza":
                    Pizza pizza = new Pizza(tokens[1], int.Parse(tokens[2]));

                    string[] doughArgs = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    pizza.Dough = new Dough(doughArgs[1], doughArgs[2], double.Parse(doughArgs[3]));

                    for (int i = 0; i < pizza.NumberOfToppings; i++)
                    {
                        string[] toppingArgs = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        pizza.AddTopping(new Topping(toppingArgs[1], double.Parse(toppingArgs[2])));
                    }

                    Console.WriteLine(pizza);
                    break;
                }
            }
            catch (ArgumentException argumentException)
            {
                Console.WriteLine(argumentException.Message);
                Environment.Exit(1);
            }

            inputLine = Console.ReadLine();
        }
    }
Beispiel #8
0
        public override APizza Make()
        {
            var pizza    = new Pizza();
            var toppings = new List <Topping>
            {
                new Topping("Basil"),
                new Topping("Marinara")
            };
            var crust = new Crust("NYStyle");
            var size  = new Size("medium");

            pizza.AddTopping(toppings);
            pizza.Crust = crust;
            pizza.Size  = size;
            return(pizza);
        }
Beispiel #9
0
        public override APizza Make()
        {
            var pizza    = new Pizza();
            var toppings = new List <Topping>
            {
                new Topping("Cheese"),
                new Topping("Tomato Sauce")
            };
            var crust = new Crust("Traditional");
            var size  = new Size("medium");

            pizza.AddTopping(toppings);
            pizza.Crust = crust;
            pizza.Size  = size;
            return(pizza);
        }
    private static Pizza SetPizza(string name, int toppingsCount)
    {
        var doughTypeAndTechnique = Console.ReadLine().Split();

        var pizza = new Pizza(name, toppingsCount);

        pizza.Dough = new Dough(doughTypeAndTechnique[1], doughTypeAndTechnique[2], int.Parse(doughTypeAndTechnique[3]));

        for (int i = 0; i < toppingsCount; i++)
        {
            var toppingData = Console.ReadLine().Split();
            pizza.AddTopping(new Topping(toppingData[1], int.Parse(toppingData[2])));
        }

        return(pizza);
    }
Beispiel #11
0
    public static void Main()
    {
        string pizzaName = Console.ReadLine().Split()[1];

        Pizza pizza = null;

        try
        {
            pizza = new Pizza(pizzaName);
        }
        catch (ArgumentException ex)
        {
            Console.WriteLine(ex.Message);
            Environment.Exit(0);
        }

        string[] doughParams = Console.ReadLine().Split();

        Dough dough = GetDough(doughParams);

        pizza.Dough = dough;

        string input = null;

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

            string toppingType          = toppingParams[1];
            int    toppingWeightInGrams = int.Parse(toppingParams[2]);

            Topping topping = null;

            try
            {
                topping = new Topping(toppingType, toppingWeightInGrams);
                pizza.AddTopping(topping);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Environment.Exit(0);
            }
        }

        Console.WriteLine(pizza);
    }
    static void Main(string[] args)
    {
        var pizzaNameAndToppingsCount = Console.ReadLine().Split();

        var doughParams = Console.ReadLine().Split();

        var pizza = new Pizza();

        try
        {
            pizza = new Pizza(pizzaNameAndToppingsCount[1]);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Environment.Exit(0);
        }
        try
        {
            pizza = new Pizza(pizzaNameAndToppingsCount[1], new Dough(doughParams[1], doughParams[2], double.Parse(doughParams[3])));
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Environment.Exit(0);
        }
        try
        {
            while (true)
            {
                var toppingParams = Console.ReadLine().Split();

                if (toppingParams[0] == "END")
                {
                    break;
                }
                pizza.AddTopping(new Topping(toppingParams[1], double.Parse(toppingParams[2])));
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Environment.Exit(0);
        }

        Console.WriteLine(pizza);
    }
Beispiel #13
0
        public void Run()
        {
            try
            {
                string[] pizzaInfo = Console.ReadLine()
                                     .Split(" ");

                string pizzaName = pizzaInfo[1];

                Pizza pizza = new Pizza(pizzaName);

                string[] doughInfo = Console.ReadLine()
                                     .Split(" ");

                string typeDough           = doughInfo[1];
                string typeBakingTechnique = doughInfo[2];
                int    doughWeight         = int.Parse(doughInfo[3]);

                Dough dough = new Dough(typeDough, typeBakingTechnique, doughWeight);

                pizza.Dough = dough;

                string toppings = Console.ReadLine();

                while (toppings != "END")
                {
                    string[] toppingInfo = toppings
                                           .Split(" ");

                    string typeTopping   = toppingInfo[1];
                    int    toppingWeight = int.Parse(toppingInfo[2]);

                    Topping topping = new Topping(typeTopping, toppingWeight);

                    pizza.AddTopping(topping);

                    toppings = Console.ReadLine();
                }

                Console.WriteLine(pizza);
            }
            catch (ArgumentException argEx)
            {
                Console.WriteLine(argEx.Message);
            }
        }
Beispiel #14
0
    static void Main(string[] args)
    {
        Pizza  pizza = new Pizza();
        Dough  dough;
        string pizzasName = "N";
        string input;

        try
        {
            while ((input = Console.ReadLine()) != "END")
            {
                var    tokens = input.Split();
                string name   = tokens[0];

                switch (name)
                {
                case "Pizza":
                    string nameInput = tokens[1];
                    pizzasName = nameInput;
                    break;

                case "Dough":
                    string flaur           = tokens[1];
                    string bakingTechnique = tokens[2];
                    double grams           = double.Parse(tokens[3]);
                    dough = new Dough(flaur, bakingTechnique, grams);
                    pizza = new Pizza(pizzasName, dough);
                    break;

                case "Topping":
                    string  type    = tokens[1];
                    double  weight  = double.Parse(tokens[2]);
                    Topping topping = new Topping(type, weight);
                    pizza.AddTopping(topping);
                    break;
                }
            }

            Console.WriteLine(pizza.ToString());
        }
        catch (ArgumentException ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Beispiel #15
0
        public void Run()
        {
            try
            {
                string[] pizzaInput = reader
                                      .ConsoleReadLine()
                                      .Split(" ");
                string[] doughInput = reader
                                      .ConsoleReadLine()
                                      .Split(" ");

                string pizzaName = pizzaInput[1];

                string flour         = doughInput[1];
                string baking        = doughInput[2];
                double weightInGrams = double.Parse(doughInput[3]);

                Dough dough = new Dough(flour, baking, weightInGrams);

                Pizza pizza = new Pizza(pizzaName, dough);

                string input = reader.ConsoleReadLine();

                while (input.Equals("END") == false)
                {
                    string[] toppingArgs = input
                                           .Split(" ");

                    string type   = toppingArgs[1];
                    double weight = double.Parse(toppingArgs[2]);

                    Topping topping = new Topping(type, weight);

                    pizza.AddTopping(topping);

                    input = reader.ConsoleReadLine();
                }

                writer.ConsoleWriteLine(pizza.ToString());
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
Beispiel #16
0
    public static void MakePizza(string[] tokens)
    {
        var numberToppings = int.Parse(tokens[2]);
        var pizza          = new Pizza(tokens[1], numberToppings);
        var doughInfo      = Console.ReadLine().Split(' ');
        var dough          = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3]));

        pizza.Dough = dough;

        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.");
    }
        static void Main(string[] args)
        {
            PizzaTopping topping = new PizzaTopping(PizzaToppingType.Cheese, "Cascaval")
            {
                Cost = 10
            };

            PizzaBase pizzaBase = new PizzaBase(PizzaBaseType.Italian, "Pizza Base 1")
            {
                Cost = 10
            };

            Pizza pizza = new Pizza(pizzaBase, "Pizza 1");

            pizza.AddTopping(topping);

            pizza.Print();
        }
Beispiel #18
0
        private void AddToppingsToPizza(Pizza pizza)
        {
            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                string[] toppingArgs = input
                                       .Split()
                                       .Skip(1)
                                       .ToArray();

                string  toppingType   = toppingArgs[0];
                double  toppingWeight = double.Parse(toppingArgs[1]);
                Topping topping       = new Topping(toppingType, toppingWeight);

                pizza.AddTopping(topping);
            }
        }
    private static string AddIngredients(Pizza pizza, string[] line, string pizzaName)
    {
        if (line[0] == "Pizza")
        {
            pizzaName = line[1];
            try
            {
                pizza.Name = pizzaName;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Environment.Exit(0);
            }
        }
        else if (line[0] == "Dough")
        {
            try
            {
                Dough dough = new Dough(line[1], line[2], double.Parse(line[3]));
                pizza.Dough = dough;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Environment.Exit(0);
            }
        }
        else if (line[0] == "Topping")
        {
            try
            {
                Topping topping = new Topping(line[1], double.Parse(line[2]));
                pizza.AddTopping(topping);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Environment.Exit(0);
            }
        }

        return pizzaName;
    }
    public static void MakePizza(Pizza pizza)
    {
        string input;
        var    toppingCounter = 0;

        while ((input = Console.ReadLine()) != "END")
        {
            if (toppingCounter > 10)
            {
                throw new Exception("Number of toppings should be in range [0..10].");
            }
            var topInfo = input.Split();
            var topping = new Topping(topInfo[1], double.Parse(topInfo[2]));
            pizza.AddTopping(topping);
            toppingCounter++;
        }

        Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories.");
    }
Beispiel #21
0
        public static void MakePizza(string[] inParams)
        {
            int   numberToppings = int.Parse(inParams[2]);
            Pizza pizza          = new Pizza(inParams[1], numberToppings);

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

            pizza.Dough = dough;

            for (var i = 0; i < numberToppings; i++)
            {
                string[] toppingInfo = Console.ReadLine().Split(' ');
                Topping  topping     = new Topping(toppingInfo[1], double.Parse(toppingInfo[2]));
                pizza.AddTopping(topping);
            }

            Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories():f2} Calories.");
        }
    public static void Main()
    {
        try
        {
            string  input          = Console.ReadLine();
            Dough   dough          = null;
            Topping currentTopping = null;
            Pizza   pizza          = new Pizza();

            while (input != "END")
            {
                string[] args = input.Split(new[] { ' ' },
                                            StringSplitOptions.RemoveEmptyEntries);
                if (args[0].ToLower() == "pizza")
                {
                    if (args.Length < 2)
                    {
                        throw new ArgumentException("Pizza name should be between 1 and 15 symbols.");
                    }
                    pizza.Name = args[1];
                }
                else if (args[0].ToLower() == "dough")
                {
                    dough       = new Dough(args[1], args[2], double.Parse(args[3]));
                    pizza.Dough = dough;
                }
                else
                {
                    currentTopping = new Topping(args[1], double.Parse(args[2]));
                    pizza.AddTopping(currentTopping);
                }

                input = Console.ReadLine();
            }

            Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:0.00} Calories.");
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
Beispiel #23
0
    static void Main()
    {
        try
        {
            string[] pizzaTokens = Console.ReadLine().Split(' ', StringSplitOptions.None);

            string pizzaName = pizzaTokens[1];

            Pizza pizza = new Pizza(pizzaName);

            string[] doughTokens = Console.ReadLine().Split(' ', StringSplitOptions.None);

            string flourType       = doughTokens[1];
            string bakingTechnique = doughTokens[2];
            int    doughWeight     = int.Parse(doughTokens[3]);

            Dough dough = new Dough(flourType, bakingTechnique, doughWeight);

            pizza.Dough = dough;

            string input = Console.ReadLine();

            while (input != "END")
            {
                string[] toppingTokens = input.Split(' ', StringSplitOptions.None);

                string type          = toppingTokens[1];
                int    toppingWeight = int.Parse(toppingTokens[2]);

                Topping topping = new Topping(type, toppingWeight);

                input = Console.ReadLine();

                pizza.AddTopping(topping);
            }
            Console.WriteLine(pizza);
        }
        catch (ArgumentException ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Beispiel #24
0
        public void Run()
        {
            try
            {
                string[] pizzaInfo = Console.ReadLine().Split();
                string   pizzaName = pizzaInfo[1];

                string[] doughInfo       = Console.ReadLine().Split();
                string   flourType       = doughInfo[1].ToLower();
                string   bakingTechnique = doughInfo[2].ToLower();
                int      doughGrams      = int.Parse(doughInfo[3]);

                Dough dough = new Dough(flourType, bakingTechnique, doughGrams);

                Pizza pizza = new Pizza(pizzaName, dough);

                string command = Console.ReadLine();

                while (command != "END")
                {
                    string[] toppingInfo  = command.Split();
                    string   toppingName  = toppingInfo[1];
                    int      toppingGrams = int.Parse(toppingInfo[2]);

                    Topping topping = new Topping(toppingName, toppingGrams);

                    pizza.AddTopping(topping);

                    command = Console.ReadLine();
                }

                Console.WriteLine(pizza);
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
            catch (InvalidOperationException ioe)
            {
                Console.WriteLine(ioe.Message);
            }
        }
    private static void MakePizza(string[] tokens)
    {
        var pizza = new Pizza(tokens[1]);

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

        pizza.Dough = dough;

        string toppings;

        while ((toppings = Console.ReadLine()) != "END")
        {
            var toppingInfo = toppings.Split();
            var topping     = new Topping(toppingInfo[1], double.Parse(toppingInfo[2]));
            pizza.AddTopping(topping);
        }

        Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():F2} Calories.");
    }
Beispiel #26
0
        public void Run()
        {
            try
            {
                string[] inputPizza = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
                string   namePizza  = inputPizza[1];

                string[] inputDough = Console.ReadLine()
                                      .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                      .ToArray();

                string inputTopping = Console.ReadLine();

                string flourTupe        = inputDough[1];
                string backingTechnique = inputDough[2];
                double weight           = double.Parse(inputDough[3]);

                Dough dough = new Dough(flourTupe, backingTechnique, weight);

                Pizza pizza = new Pizza(namePizza, dough);

                while (inputTopping != "END")
                {
                    string[] toppingInfo = inputTopping.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();

                    string typeDough  = toppingInfo[1];
                    double gramsDough = double.Parse(toppingInfo[2]); //double !!!!

                    Topping topping = new Topping(typeDough, gramsDough);

                    pizza.AddTopping(topping);

                    inputTopping = Console.ReadLine();
                }
                Console.WriteLine(pizza);
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
Beispiel #27
0
    private static void CreatePizza(string[] inputParts)
    {
        Pizza pizza = new Pizza(inputParts[1]);

        inputParts = Console.ReadLine().Split();
        Dough pizzaDough = new Dough(inputParts[1], inputParts[2], double.Parse(inputParts[3]));

        pizza.Dought = pizzaDough;
        inputParts   = Console.ReadLine().Split();
        while (inputParts[0] != "END")
        {
            Topping pizzaTopping = new Topping(inputParts[1], double.Parse(inputParts[2]));
            pizza.AddTopping(pizzaTopping);
            inputParts = Console.ReadLine().Split();
        }
        if (pizza.Toppings.Count > 10)
        {
            throw new ArgumentException("Number of toppings should be in range [0..10].");
        }
        Console.WriteLine(pizza);
    }
Beispiel #28
0
    private static void Main()
    {
        try
        {
            Pizza pizza = new Pizza(Console.ReadLine());
            Dough dough = new Dough(Console.ReadLine());
            pizza.Dough = dough;

            string input;
            while ((input = Console.ReadLine()) != "END")
            {
                Topping topping = new Topping(input);
                pizza.AddTopping(topping, pizza.Toppings);
            }
            Console.WriteLine(pizza);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Beispiel #29
0
        public void Run()
        {
            Pizza  pizza   = null;
            string command = string.Empty;

            while ((command = Console.ReadLine()) != "END")
            {
                try
                {
                    string[] input = command.Split();
                    if (input[0] == "Pizza")
                    {
                        pizza = MakePizza(input);
                    }
                    if (input[0] == "Dough")
                    {
                        pizza.Dough = MakeDough(input);
                    }
                    if (input[0] == "Topping")
                    {
                        Topping topping = MakeTopping(input);
                        try
                        {
                            pizza.AddTopping(topping);
                        }
                        catch (ArgumentException ae)
                        {
                            Console.WriteLine(ae.Message);
                            return;
                        }
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                    return;
                }
            }
            Console.WriteLine(pizza);
        }
Beispiel #30
0
        public void Run()
        {
            try
            {
                string[] pizzaData = Console.ReadLine().Split();

                string name = pizzaData[1];

                string[] doughData = Console.ReadLine().Split();


                string type            = doughData[1];
                string bakingTechnique = doughData[2];
                int    weight          = int.Parse(doughData[3]);

                Dough dough = new Dough(type, bakingTechnique, weight);
                Pizza pizza = new Pizza(name, dough);

                string command = Console.ReadLine();

                while (command != "END")
                {
                    string[] toppingData   = command.Split();
                    string   toppingType   = toppingData[1];
                    int      toppingWeight = int.Parse(toppingData[2]);

                    Topping currentTopping = new Topping(toppingType, toppingWeight);

                    pizza.AddTopping(currentTopping);

                    command = Console.ReadLine();
                }

                Console.WriteLine(pizza.ToString());
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }