public void Run()
        {
            try
            {
                string[] pizzaInfo   = Console.ReadLine().Split();
                string[] doughtInfo  = Console.ReadLine().Split();
                string   pizzaName   = pizzaInfo[1];
                string   doughType   = doughtInfo[1];
                string   doughModel  = doughtInfo[2];
                double   weightDough = double.Parse(doughtInfo[3]);

                Pizza pizza = new Pizza(pizzaName);

                pizza.AddDough(doughType, doughModel, weightDough);

                string input;

                while ((input = Console.ReadLine()) != END_INGRIDIENTS)
                {
                    string[] toppingInfo   = input.Split();
                    string   toppingType   = toppingInfo[1];
                    double   weightTopping = double.Parse(toppingInfo[2]);
                    Topping  topping       = new Topping(toppingType, weightTopping);
                    pizza.AddToppings(topping);
                }

                Console.WriteLine(pizza);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#2
0
        public void Run()
        {
            string[] pizzaArg    = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            string[] doughArg    = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            string   pizzaName   = pizzaArg[1];
            string   doughFlour  = doughArg[1];
            string   doughType   = doughArg[2];
            double   doughWeight = double.Parse(doughArg[3]);

            try
            {
                Pizza pizza = CreatePizza(pizzaName);
                Dough dough = CreateDough(doughFlour, doughType, doughWeight);
                pizza.AddDough(dough);

                string input;

                while ((input = Console.ReadLine()) != END_LOOP)
                {
                    string[] toppingArg    = input.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
                    string   toppingName   = toppingArg[1];
                    double   toppingWeight = double.Parse(toppingArg[2]);
                    Topping  topping       = CreateTopping(toppingName, toppingWeight);
                    pizza.AddTopping(topping);
                }

                Console.WriteLine(pizza.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#3
0
    public static void Main()
    {
        try
        {
            var input       = Console.ReadLine();
            var inputTokens = input.Split();
            var pizza       = new Pizza(inputTokens[1]);

            input       = Console.ReadLine();
            inputTokens = input.Split();
            var flourType        = inputTokens[1];
            var backingTechnique = inputTokens[2];
            var weight           = double.Parse(inputTokens[3]);
            pizza.AddDough(new Dough(flourType, backingTechnique, weight));

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

            Console.WriteLine(pizza.ToString());
        }
        catch (ArgumentException exception)
        {
            Console.WriteLine(exception.Message);
        }
    }
示例#4
0
        static void Main(string[] args)
        {
            try
            {
                string   comand;
                string[] nameOfpizza = Console.ReadLine().Split(" ");
                Pizza    pizza       = new Pizza(nameOfpizza[1]);
                string[] doughTokens = Console.ReadLine().Split(" ");

                pizza.AddDough(doughTokens[1], doughTokens[2], doughTokens[3].ToLower());



                while ((comand = Console.ReadLine()) != "END")
                {
                    string[] topisngsTokens = comand.Split(" ");
                    Topping  topping        = new Topping(topisngsTokens[1].ToLower(), topisngsTokens[2].ToLower());
                    pizza.AddTopping(topping);
                }
                pizza.Pizzacalories();
                Console.WriteLine(pizza);
            }

            catch (Exception ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
示例#5
0
        static void Main(string[] args)
        {
            Dough   dough   = new Dough();
            Topping topping = new Topping();
            Pizza   pizza   = new Pizza();

            var pizzaInput = Console.ReadLine().Split(' ').ToList();

            try
            {
                pizza = new Pizza(pizzaInput[1]);
            }
            catch (ArgumentException argEx)
            {
                Console.WriteLine(argEx.Message);
                return;
            }
            var doughInput       = Console.ReadLine().Split(' ').ToList();
            var flourType        = doughInput[1];
            var backingTechnique = doughInput[2];
            var doughWeigth      = decimal.Parse(doughInput[3]);

            try
            {
                dough = new Dough(flourType, backingTechnique, doughWeigth);
                pizza.AddDough(dough);
            }
            catch (ArgumentException argEx)
            {
                Console.WriteLine(argEx.Message);
                return;
            }

            var input = Console.ReadLine();

            while (input != "END")
            {
                var toppingInput  = input.Split(' ').ToList();
                var toppingType   = toppingInput[1];
                var toppingWeigth = decimal.Parse(toppingInput[2]);
                try
                {
                    topping = new Topping(toppingType, toppingWeigth);
                    pizza.AddTopping(topping);
                }
                catch (ArgumentException argEx)
                {
                    Console.WriteLine(argEx.Message);
                    return;
                }
                input = Console.ReadLine();
            }
            Console.WriteLine(pizza);
        }
示例#6
0
        private static void MakeDough(string[] data)
        {
            FlourType       flour  = FlourType.white;
            BakingTechnique tech   = BakingTechnique.homemade;
            decimal         weight = decimal.Parse(data[3]);

            switch (data[1].ToLower())
            {
            case "white":
                break;

            case "wholegrain":
                flour = FlourType.wholegrain;
                break;

            default:
                throw new ArgumentException("Invalid type of dough.");
            }
            switch (data[2].ToLower())
            {
            case "crispy":
                tech = BakingTechnique.crispy;
                break;

            case "chewy":
                tech = BakingTechnique.chewy;
                break;

            case "homemade":
                break;

            default:
                throw new ArgumentException("Invalid type of dough.");
            }
            Dough dough = new Dough(flour, tech, weight);

            pizza.AddDough(dough);
            //Console.WriteLine("{0:f2}", dough.Calories);
        }
示例#7
0
    static void Main(string[] args)
    {
        try
        {
            Pizza    pizza           = new Pizza(Console.ReadLine().Split()[1]);
            string[] doughArg        = Console.ReadLine().Split();
            string   flourType       = doughArg[1];
            string   bakingTechnique = doughArg[2];
            int      weight          = int.Parse(doughArg[3]);
            pizza.AddDough(flourType, bakingTechnique, weight);

            string inputTopings;
            while ((inputTopings = Console.ReadLine()) != "END")
            {
                string[] toppingArg = inputTopings.Split();
                pizza.AddTopping(toppingArg[1], int.Parse(toppingArg[2]));
            }
            Console.WriteLine($"{pizza.Name} - {pizza.CalCaloriesPizza():f2} Calories.");
        }
        catch (ArgumentException argEx)
        {
            Console.WriteLine(argEx.Message);
        }
    }