Esempio n. 1
0
        public static void Main()
        {
            try
            {
                double   allCalories = 0;
                string   pizzaInput  = Console.ReadLine();
                string[] pizzaToken  = pizzaInput.Split();
                if (string.IsNullOrWhiteSpace(pizzaToken[1]) || pizzaToken[1].Length > 15)
                {
                    throw new ArgumentException("Pizza name should be between 1 and 15 symbols.");
                }
                var pizza = new Pizza(pizzaToken[1]);

                string   doughInput = Console.ReadLine();
                string[] doughToken = doughInput.Split();

                string flourType       = doughToken[1];
                string bakingTechnique = doughToken[2];
                double weightDough     = double.Parse(doughToken[3]);

                var dough = new Dough(flourType, bakingTechnique, weightDough);
                dough.ClaculateCalories();
                allCalories += dough.Calories;

                string toppingInput = Console.ReadLine();

                while (toppingInput != "END")
                {
                    string[] toppingToken = toppingInput.Split();

                    string type          = toppingToken[1];
                    double weightTopping = double.Parse(toppingToken[2]);

                    var topping = new Topping(type, weightTopping);
                    pizza.Toppings(topping);
                    topping.CalculateCalories();
                    allCalories += topping.Calories;

                    toppingInput = Console.ReadLine();
                }
                Console.WriteLine($"{pizzaToken[1]} - {allCalories:f2} Calories.");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                Pizza pizza = CreatePizza();
                Dough dough = CreateDough();

                pizza.Dough = dough;
                AddToppingsToPizza(pizza);
                Console.WriteLine(pizza.ToString());
            }

            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
Esempio n. 3
0
        public static void Main()
        {
            try
            {
                Pizza pizza = null;

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

                    switch (command)
                    {
                    case "Pizza":
                        string pizzaName = data[1];
                        pizza = new Pizza(pizzaName);
                        break;

                    case "Dough":
                        string flourType       = data[1];
                        string bakingTechnique = data[2];
                        double doughWeight     = double.Parse(data[3]);

                        Dough dough = new Dough(flourType, bakingTechnique, doughWeight);
                        pizza.AddDough(dough);
                        break;

                    case "Topping":
                        string toppingType   = data[1];
                        double toppingWeight = double.Parse(data[2]);

                        Topping topping = new Topping(toppingType, toppingWeight);
                        pizza.AddTopping(topping);
                        break;
                    }
                }

                Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            Pizza    pizza = null;

            try
            {
                pizza = new Pizza(input[1]);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }


            input = Console.ReadLine().Split();
            Dough dough = null;

            try
            {
                dough = new Dough(input[1], input[2], double.Parse(input[3]));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            pizza.Dough = dough;

            while ((input = Console.ReadLine().Split())[0] != "END")
            {
                try
                {
                    pizza.AddTopping(input[1], double.Parse(input[2]));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return;
                }
            }

            Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories.");
        }
Esempio n. 5
0
        private static void MakePizza(string[] tokens)
        {
            var pizza     = new Pizza(tokens[1], int.Parse(tokens[2]));
            var doughInfo = Console.ReadLine().Split();
            var dough     = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3]));

            pizza.Dough = dough;
            var numberOfToppings = int.Parse(tokens[2]);

            for (int i = 0; i < numberOfToppings; i++)
            {
                var toppingInfo = Console.ReadLine().Split();
                var topping     = new Topping(toppingInfo[1], double.Parse(toppingInfo[2]));
                pizza.AddTopping(topping);
            }
            Console.WriteLine($"{pizza.Name} - {pizza.getCalories():F2} Calories.");
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            string command = Console.ReadLine();
            Dough  dough   = new Dough();
            string name    = "";

            try
            {
                string[] arr = command.Split();
                name = arr[1];

                arr = Console.ReadLine().Split();

                string  flowerType = arr[1];
                string  technique  = arr[2];
                decimal weight     = decimal.Parse(arr[3]);

                Pizza pizza = new Pizza(name, new Dough(flowerType, technique, weight));

                command = Console.ReadLine();

                while (command != "END")
                {
                    arr = command.Split();
                    string type = arr[0];

                    switch (type)
                    {
                    case "Topping":
                        string  toppingType   = arr[1];
                        decimal toppingWeight = decimal.Parse(arr[2]);

                        Topping topping = new Topping(toppingType, toppingWeight);
                        pizza.AddTopping(topping);
                        break;
                    }
                    command = Console.ReadLine();
                }
                Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 7
0
        public static void Main(string[] args)
        {
            try
            {
                string[] inputCommand = Console.ReadLine().Split();
                string   pizzaName    = inputCommand[1];

                string[] inputInfo = Console.ReadLine().Split().ToArray();

                string doughType      = inputInfo[1].ToLower();
                string bakingTehnique = inputInfo[2].ToLower();
                double weight         = double.Parse(inputInfo[3]);

                Dough dough = new Dough(doughType, bakingTehnique, weight);

                Pizza pizza = new Pizza(pizzaName, dough);

                while (true)
                {
                    string inputArg = Console.ReadLine();

                    if (inputArg.Equals("END"))
                    {
                        break;
                    }

                    string[] input = inputArg.Split().ToArray();

                    string toppingType   = input[1];
                    double toppingWeight = double.Parse(input[2]);

                    Topping topping = new Topping(toppingType, toppingWeight);


                    pizza.AddTopping(topping);
                    //pizza.GetTotalPizzaCalories();
                }

                Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            string[] productName = Console.ReadLine().Split();
            string   pizzaName   = productName[1];


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

            try
            {
                baseDough = new Dough(dough[1], dough[2], double.Parse(dough[3]));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
            baseDough = new Dough(dough[1], dough[2], double.Parse(dough[3]));
            Pizza pizza = new Pizza(pizzaName)
            {
                Dough = baseDough
            };

            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                var     tokens = input.Split();
                Topping topping;
                try
                {
                    topping = new Topping(tokens[1], double.Parse(tokens[2]));
                    pizza.ListOfTopings(topping);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return;
                }
                //topping = new Topping(tokens[1], double.Parse(tokens[2]));
            }
            Console.WriteLine(pizza);
        }
        public static void Main(string[] args)
        {
            try
            {
                string pizzaName = Console.ReadLine()
                                   .Split()[1];

                string[] doughInput = Console.ReadLine()
                                      .Split()
                                      .ToArray();

                string flourType       = doughInput[1];
                string bakingTechnique = doughInput[2];
                double weight          = double.Parse(doughInput[3]);

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

                Pizza pizza = new Pizza(pizzaName, dough);

                string command = Console.ReadLine();

                while (command != "END")
                {
                    string[] inputTopping = command
                                            .Split()
                                            .ToArray();

                    string toppingProduct  = inputTopping[1];
                    double weightOfTopping = double.Parse(inputTopping[2]);

                    Topping topping = new Topping(toppingProduct, weightOfTopping);

                    pizza.AddTopping(topping);

                    command = Console.ReadLine();
                }

                Console.WriteLine($"{pizza.Name} - {pizza.PizzaTotalCalories:F2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            try
            {
                while (true)
                {
                    string cmd = Console.ReadLine();
                    if (cmd == "END")
                    {
                        break;
                    }

                    string[] cmdArgs = cmd.Split();
                    string   type    = cmdArgs[0];

                    if (type == "Dough")
                    {
                        string flourType   = cmdArgs[1];
                        string backingType = cmdArgs[2];
                        double weight      = double.Parse(cmdArgs[3]);

                        dough = new Dough(flourType, backingType, weight);
                        pizza = new Pizza(pizzaName, dough);
                    }
                    else if (type == "Topping")
                    {
                        string toppingType = cmdArgs[1];
                        double weight      = double.Parse(cmdArgs[2]);

                        Topping topping = new Topping(toppingType, weight);
                        pizza.AddTopping(topping);
                    }
                    else if (type == "Pizza")
                    {
                        pizzaName = cmdArgs[1];
                    }
                }
                Console.WriteLine(pizza);
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
Esempio n. 11
0
        public void Run()
        {
            Dough   dough   = null;
            Topping topping = null;
            Pizza   pizza   = null;

            try
            {
                string input = Console.ReadLine();
                while (input != "end")
                {
                    var    pizzaInput = input.Split();
                    string pizzaName  = pizzaInput[1];

                    input = Console.ReadLine().ToLower();

                    dough = CreateDough(input);

                    pizza = new Pizza(pizzaName, dough);

                    input = Console.ReadLine().ToLower();

                    while (input != "end")
                    {
                        topping = CreateTopping(input);
                        pizza.AddTopping(topping);

                        input = Console.ReadLine().ToLower();
                    }
                }

                //Console.WriteLine($"{dough.GetTotalCalories():F2}");
                //Console.WriteLine($"{topping.GetTotalCalories():F2}");

                double result = pizza.GetTotalCalories();

                Console.WriteLine($"{pizza.Name} - {result:F2} Calories.");
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 12
0
        private static void MakePizza(string[] param)
        {
            var pizzaName        = param[1];
            var numberOfToppings = int.Parse(param[2]);
            var pizza            = new Pizza(pizzaName, numberOfToppings);
            var doughParam       = Console.ReadLine().Split();
            var dough            = new Dough(doughParam[1], doughParam[2], double.Parse(doughParam[3]));

            pizza.Dough = dough;

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

            Console.WriteLine($"{pizza.Name} - {pizza.GetPizzaCallories():f2} Calories.");
        }
Esempio n. 13
0
        public static void Main(string[] args)
        {
            string[] pizzaOrder = Console.ReadLine()
                                  .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            string[] supplements = Console.ReadLine()
                                   .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            try
            {
                string name             = pizzaOrder[1];
                string flourType        = supplements[1];
                string backingTechnique = supplements[2];
                int    weight           = int.Parse(supplements[3]);

                Dough dough = new Dough(flourType, backingTechnique, weight);
                Pizza pizza = new Pizza(name, dough);

                string command = Console.ReadLine();

                while (command != "END")
                {
                    supplements = command
                                  .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    string type          = supplements[1];
                    int    weightTopping = int.Parse(supplements[2]);

                    Topping topping = new Topping(type, weightTopping);
                    pizza.AddTopping(topping);

                    command = Console.ReadLine();
                }

                pizza.CalculatePizzaCalories();
                Console.WriteLine(pizza);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                return;
            }
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            List <Topping> toppings      = new List <Topping>();
            string         pizzaName     = string.Empty;
            string         doughFlour    = string.Empty;
            string         doughType     = string.Empty;
            double         doughtWeight  = 0;
            string         toppingType   = string.Empty;
            double         toppingWeight = 0;

            string input = Console.ReadLine();

            while (input != "END")
            {
                if (input.Contains("Pizza"))
                {
                    pizzaName = input.Split(' ', StringSplitOptions.RemoveEmptyEntries)[1];
                }
                else if (input.Contains("Dough"))
                {
                    string[] doughParams = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                    doughFlour   = doughParams[1].ToLower();
                    doughType    = doughParams[2].ToLower();
                    doughtWeight = double.Parse(doughParams[3]);
                }
                else if (input.Contains("Topping"))
                {
                    string[] toppingParams = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                    toppingType   = toppingParams[1].ToLower();
                    toppingWeight = double.Parse(toppingParams[2]);
                    Topping topping = new Topping(toppingType, toppingWeight);
                    toppings.Add(topping);
                }
                input = Console.ReadLine();
            }

            Dough dough = new Dough(doughtWeight, doughType, doughFlour);


            Pizza pizza = new Pizza(pizzaName, toppings, dough);

            Console.WriteLine($"{pizza.GetName()} - {pizza.TotalCalories():F2} Calories.");
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            try
            {
                Pizza pizza = GetPizza();

                Dough dough = GetDough();

                pizza.SetDough(dough);

                AddToppings(pizza);

                Console.WriteLine(pizza);
            }
            catch (ArgumentException argEx)
            {
                Console.WriteLine(argEx.Message);
            }
        }
Esempio n. 16
0
        public static double ReturnFlourModifier(Dough dough)
        {
            double modifier = 0;

            switch (dough.Flour.ToLower())
            {
            case "white":
                modifier = 1.5;
                break;

            case "wholegrain":
                modifier = 1;
                break;

            default:
                break;
            }
            return(modifier);
        }
Esempio n. 17
0
        public static void Main(string[] args)
        {
            try
            {
                var pizzaParameters = Console.ReadLine()
                                      .Split();

                var pizzaName = pizzaParameters[1];

                var doughParameters = Console.ReadLine()
                                      .Split();
                var flourType       = doughParameters[1];
                var bakingTechnique = doughParameters[2];
                var grams           = double.Parse(doughParameters[3]);

                var dough = new Dough(flourType, bakingTechnique, grams);
                var pizza = new Pizza(pizzaName, dough);

                while (true)
                {
                    var inputLine = Console.ReadLine();
                    if (inputLine == "END")
                    {
                        break;
                    }

                    var toppingParameters = inputLine
                                            .Split();
                    var toppingName  = toppingParameters[1];
                    var toppingGrams = double.Parse(toppingParameters[2]);

                    var topping = new Topping(toppingName, toppingGrams);

                    pizza.AddTopping(topping);
                }

                Console.WriteLine($"{pizza.Name} - {pizza.CalculateCalories():F2} Calories.");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            // System.Globalization.CultureInfo invariantCulture =
            // System.Globalization.CultureInfo.InvariantCulture;


            var pizzaName = Console.ReadLine().Split()[1];

            string[] doughArgs       = Console.ReadLine().Split();
            string   flourType       = doughArgs[1];
            string   bakingTechnique = doughArgs[2];
            int      weight          = int.Parse(doughArgs[3]);

            try
            {
                var dough = new Dough(flourType, bakingTechnique, weight);
                var pizza = new Pizza(pizzaName, dough);

                while (true)
                {
                    var line = Console.ReadLine();
                    if (line.ToLower() == "end")
                    {
                        break;
                    }

                    var parts = line.Split();

                    string toppingName   = parts[1];
                    int    toppingWeight = int.Parse(parts[2]);

                    Topping topping = new Topping(toppingName, toppingWeight);

                    pizza.AddTopping(topping);
                }

                Console.WriteLine($"{pizzaName} - {pizza.GetCalories():f2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 19
0
        static void Main()
        {
            try
            {
                string[] pizzaArgs = Console.ReadLine().Split();
                string   pizzaName = pizzaArgs[1];

                string[] doughArgs        = Console.ReadLine().Split();
                string   flourType        = doughArgs[1];
                string   backingTechnique = doughArgs[2];
                double   weight           = double.Parse(doughArgs[3]);

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

                Pizza pizza = new Pizza(pizzaName, dough);

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

                while (toppingArgs[0] != "END")
                {
                    string toppingType   = toppingArgs[1];
                    double toppingWeight = double.Parse(toppingArgs[2]);

                    Topping topping = new Topping(toppingType, toppingWeight);

                    pizza.AddTopping(topping);

                    toppingArgs = Console.ReadLine().Split();
                }

                Console.WriteLine($"{pizza.Name} - {pizza.GetTotalCalories().ToString("f2")} Calories.");
            }

            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }

            catch (InvalidOperationException ioe)
            {
                Console.WriteLine(ioe.Message);
            }
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            try
            {
                string[] dataPizza = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

                string typePizza = string.Empty;
                if (dataPizza.Length == 2)
                {
                    typePizza = dataPizza[1];
                }

                Pizza pizza = new Pizza(typePizza);


                dataPizza = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
                string flourType        = dataPizza[1];
                string backingTechnique = dataPizza[2];
                double weight           = double.Parse(dataPizza[3]);

                Dough dough = new Dough(flourType, backingTechnique, weight);
                pizza.DoughPizza = dough;

                dataPizza = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

                while (dataPizza[0] != "END")
                {
                    string toppingType   = dataPizza[1];
                    double toppingWeight = double.Parse(dataPizza[2]);

                    Topping topping = new Topping(toppingType, toppingWeight);
                    pizza.AddTopping(topping);

                    dataPizza = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
                }

                Console.WriteLine(pizza.ToString());
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 21
0
        public static void Main(string[] args)
        {
            string pizzaName = Console.ReadLine().Split()[1];

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

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

            try
            {
                Dough dough = new Dough(flourType, bakingTechnique, weight);

                Pizza pizza = new Pizza(pizzaName, dough);

                while (true)
                {
                    string line = Console.ReadLine();

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

                    string[] toppingData = line.Split().ToArray();

                    string toppingName   = toppingData[1];
                    int    toppingWeight = int.Parse(toppingData[2]);

                    Topping topping = new Topping(toppingName, toppingWeight);

                    pizza.AddTopping(topping);
                }

                Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():F2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            var pizzaArgs = Console.ReadLine().Split();
            var doughArgs = Console.ReadLine().Split();

            var dough = new Dough(doughArgs[1], doughArgs[2], double.Parse(doughArgs[3]));
            var pizza = new Pizza(pizzaArgs[1], dough);

            string input = String.Empty;

            while ((input = Console.ReadLine()) != "END")
            {
                var inputArgs = input.Split();

                var toppings = new Topping(inputArgs[1], double.Parse(inputArgs[2]));
                pizza.AddToppings(toppings);
            }

            Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:F2} Calories.");
        }
        static void Main(string[] args)
        {
            try
            {
                string pizzaName = Console.ReadLine().Split()[1];

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

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

                Pizza pizza = new Pizza(pizzaName, dough);

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

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

                    string[] toppingData   = command.Split();
                    string   toppingName   = toppingData[1];
                    int      toppingWeight = int.Parse(toppingData[2]);

                    Topping topping = new Topping(toppingName, toppingWeight);

                    pizza.AddTopping(topping);
                }

                Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:f2} Calories.");
            }
            catch (Exception ex)
                when(ex is ArgumentException || ex is InvalidOperationException)
                {
                    Console.WriteLine(ex.Message);
                }
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            try
            {
                double totalCalories = 0;
                var    input         = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                Pizza  pizza         = new Pizza(input[1]);

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

                var input3 = Console.ReadLine();

                while (input3 != "END")
                {
                    if (input3 == "END")
                    {
                        break;
                    }

                    var     tokens  = input3.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                    Topping topping = new Topping(tokens[1], double.Parse(tokens[2]));
                    pizza.AddTopping(topping);

                    input3 = Console.ReadLine();
                }

                double toppungCalories = 0;
                foreach (var topping in pizza.Toppings)
                {
                    toppungCalories += topping.CalculateCalories();
                }

                totalCalories = dough.CalculateCalories() + toppungCalories;
                Console.WriteLine($"{pizza.Name} - {totalCalories:f2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 25
0
        static void Main(string[] args)
        {
            try
            {
                string[] pizzaArgs = Console.ReadLine().Split();

                string pizzaName = pizzaArgs[1];

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

                string flourType       = inputArgs[1];
                string bakingTechnique = inputArgs[2];
                double weight          = double.Parse(inputArgs[3]);

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

                Pizza pizza = new Pizza(pizzaName, dough);

                string inputLine = Console.ReadLine();

                while (inputLine != "END")
                {
                    string[] toppingArgs = inputLine.Split();

                    string toppingType   = toppingArgs[1];
                    double weightTopping = double.Parse(toppingArgs[2]);

                    Topping topping = new Topping(toppingType, weightTopping);

                    pizza.AddTopping(topping);

                    inputLine = Console.ReadLine();
                }

                Console.WriteLine($"{pizza.Name} - {pizza.GetTotalCalories().ToString("F2")} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 26
0
        public void Run()
        {
            try
            {
                var pizzaName = Console.ReadLine().Split().Skip(1).First();
                var pizza     = new Pizza(pizzaName);
                var doughInfo = Console.ReadLine()
                                .ToLower()
                                .Split()
                                .Skip(1)
                                .ToArray();

                var type      = doughInfo[0];
                var technique = doughInfo[1];
                var grams     = int.Parse(doughInfo[2]);
                var dough     = new Dough(type, technique, grams);

                pizza.ChoocePizzasDough(dough);

                var command = string.Empty;
                while ((command = Console.ReadLine()) != "END")
                {
                    var toppingInfo = command
                                      .ToLower()
                                      .Split()
                                      .Skip(1)
                                      .ToArray();

                    var toppingType  = toppingInfo[0];
                    var toppingGrams = int.Parse(toppingInfo[1]);
                    var topping      = new Topping(toppingType, toppingGrams);
                    pizza.AddTopping(topping);
                }

                Console.WriteLine($"{pizza.GetPizzasName()} - {pizza.GetTotalCalories():F2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 27
0
        public void Proceed()
        {
            try
            {
                var pizzaArgs = Reading();

                var pizzaName = pizzaArgs[1];

                var doughArgs = Reading();

                var doughFlourType       = doughArgs[1];
                var doughBakingTechnique = doughArgs[2];
                var doughWeight          = double.Parse(doughArgs[3]);

                var dough = new Dough(doughFlourType, doughBakingTechnique, doughWeight);

                var pizza = new Pizza(pizzaName, dough);

                var input = "";
                while ((input = Console.ReadLine()) != "END")
                {
                    var toppingArgs = input
                                      .ToLower()
                                      .Split()
                                      .ToList();

                    var toppingType   = toppingArgs[1];
                    var toppingWeight = double.Parse(toppingArgs[2]);

                    var topping = new Topping(toppingType, toppingWeight);

                    pizza.AddTopping(topping);
                }

                Console.WriteLine(pizza);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 28
0
        public static void Main()
        {
            try
            {
                string[] pizzaInfo = Console.ReadLine().Split();

                string pizzaName = pizzaInfo[1];

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

                string flourType       = doughInfo[1];
                string bakingTechnique = doughInfo[2];
                double doughtWeight    = double.Parse(doughInfo[3]);

                Dough dough = new Dough(flourType, bakingTechnique, doughtWeight);
                Pizza pizza = new Pizza(pizzaName, new List <Topping>(), dough);

                string command = Console.ReadLine();

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

                    string toppingType   = toppingInfo[1];
                    double toppingWeight = double.Parse(toppingInfo[2]);

                    Topping topping = new Topping(toppingType, toppingWeight);

                    pizza.AddTopping(topping);

                    command = Console.ReadLine();
                }

                Console.WriteLine(pizza);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Esempio n. 29
0
        public static void Main(string[] args)
        {
            var pizza = new Pizza();

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "END")
                {
                    break;
                }
                string[] tokens  = input.Split();
                string   command = tokens[0];



                if (command == "Dough")
                {
                    string flour      = tokens[1];
                    string bakingTech = tokens[2];
                    double weight     = double.Parse(tokens[3]);
                    var    dough      = new Dough(flour, bakingTech, weight);
                    pizza.Dough = dough;
                }
                else if (command == "Topping")
                {
                    string type    = tokens[1];
                    double weight  = double.Parse(tokens[2]);
                    var    topping = new Topping(type, weight);
                    pizza.AddTopping(topping);
                }
                else if (command == "Pizza")
                {
                    string name = tokens[1];
                    pizza.Name = name;
                }
            }

            Console.WriteLine($"{pizza.Name} - {pizza.Calories():f2} Calories.");
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            var pizzaName = Console.ReadLine().Split()[1];
            var doughData = Console.ReadLine().Split();

            var flourType     = doughData[1];
            var bakingTechnik = doughData[2];
            var Weight        = int.Parse(doughData[3]);

            try
            {
                var dough = new Dough(flourType, bakingTechnik, Weight);
                var pizza = new Pizza(pizzaName, dough);

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

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

                    var parts = line.Split();

                    var toppingName   = parts[1];
                    var toppingWeight = int.Parse(parts[2]);

                    var topping = new Topping(toppingName, toppingWeight);

                    pizza.AddTopping(topping);
                }

                Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():f2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }