static void Main(string[] args)
        {
            try
            {
                string cmd             = Console.ReadLine();
                string pizzaName       = string.Empty;
                string doughType       = string.Empty;
                string bakingTechnique = string.Empty;
                double doughWeight     = 0;
                string toppingType     = string.Empty;
                double toppingWeight   = 0;

                var data = cmd.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                if (data[0] == "Pizza")
                {
                    pizzaName = data[1];
                }

                Pizza pizza = new Pizza(pizzaName);

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

                if (data[0] == "Dough")
                {
                    doughType       = data[1];
                    bakingTechnique = data[2];
                    doughWeight     = double.Parse(data[3]);
                    Dough dough = new Dough(doughType, bakingTechnique, doughWeight);
                    pizza.Dough = dough;
                }

                cmd = Console.ReadLine();
                while (cmd != "END")
                {
                    data = cmd.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    if (data[0] == "Topping")
                    {
                        toppingType   = data[1];
                        toppingWeight = double.Parse(data[2]);
                        var topping = new Topping(toppingType, toppingWeight);
                        pizza.AddToppings(topping);
                    }

                    cmd = Console.ReadLine();
                }

                Console.WriteLine(pizza.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        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], int.Parse(doughInfo[3]));
            pizza.Dough = dough;

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

            Console.WriteLine($"{pizza.Name} - {pizza.CalculateCalories():f2} Calories.");
        }
示例#3
0
        public static void Main()
        {
            string input;
            Pizza  pizza = new Pizza("Default");

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

                try
                {
                    if (tokens[0] == "Pizza")
                    {
                        var name = tokens[1];
                        pizza.Name = name;
                    }
                    else if (tokens[0] == "Dough")
                    {
                        var flour     = tokens[1].ToLower();
                        var technique = tokens[2].ToLower();
                        var weight    = int.Parse(tokens[3]);
                        var dough     = new Dough(flour, technique, weight);
                        pizza.Calories += dough.Calories;
                    }
                    else
                    {
                        var name    = tokens[1];
                        var weight  = int.Parse(tokens[2]);
                        var topping = new Topping(name, weight);
                        pizza.AddTopping(topping);
                        pizza.Calories += topping.Calories;
                    }
                }
                catch (ArgumentException exception)
                {
                    Console.WriteLine(exception.Message);
                    return;
                }
            }

            Console.WriteLine($"{pizza.Name} - {pizza.Calories:F2} Calories.");
        }
示例#4
0
        public static void Main(string[] args)
        {
            try
            {
                string[] inputNamePizza = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                string   pizzaName      = inputNamePizza[1];
                Pizza    pizza          = new Pizza(pizzaName);

                string   inputDough = Console.ReadLine();
                string[] splitted   = inputDough.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                string flourType  = splitted[1];
                string bakingTech = splitted[2];
                double grams      = double.Parse(splitted[3]);
                Dough  dough      = new Dough(flourType, bakingTech, grams);

                pizza.Dough = dough;
                //Pizza pizza = new Pizza(pizzaName, dough);

                Topping topping      = null;
                string  inputTopping = Console.ReadLine();
                while (inputTopping != "END")
                {
                    string[] secondSplitted = inputTopping.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

                    string toppingType  = secondSplitted[1];
                    double toppingGrams = double.Parse(secondSplitted[2]);
                    topping = new Topping(toppingType, toppingGrams);
                    pizza.AddTopping(topping);

                    inputTopping = Console.ReadLine();
                }

                Console.WriteLine($"{pizzaName} - {pizza.CalculateTotalCalories():F2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#5
0
        public static void Main(string[] args)
        {
            try
            {
                string pizzaName = Console.ReadLine().Split()[1];

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

                string flourType   = input[1];
                string bakingTyype = input[2];
                double weight      = double.Parse(input[3]);

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

                Pizza pizza = new Pizza(pizzaName, dough);

                string command = Console.ReadLine();

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

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

                    Topping topping = new Topping(toppingType, toppingWeight);

                    pizza.AddTopping(topping);

                    command = Console.ReadLine();
                }

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

                var input = Console.ReadLine()
                            .Split(" ");

                var flourType      = input[1];
                var bakingTehnique = input[2];
                var weight         = double.Parse(input[3]);

                Dough dough = new Dough(flourType, bakingTehnique, weight);
                Pizza pizza = new Pizza(pizzaName, dough);

                var command = Console.ReadLine();

                while (command != "END")
                {
                    var toppinginput = command
                                       .Split(" ");

                    var toppingName   = toppinginput[1];
                    var weightTopping = double.Parse(toppinginput[2]);

                    Topping topping = new Topping(toppingName, weightTopping);
                    pizza.AddToping(topping);

                    command = Console.ReadLine();
                }
                Console.WriteLine($"{pizzaName} - {pizza.SumTotalCaloriesOfPizza():f2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }