Beispiel #1
0
        private static void GetPizza(Pizza pizza)
        {
            while (true)
            {
                string input = Console.ReadLine();

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

                string[] hold = input.Split();

                string comand = hold[0];

                if (comand == "Pizza")
                {
                    pizza.Name = hold[1];
                }
                else if (comand == "Dough")
                {
                    string curentFlouer  = hold[1];
                    string curentBaking  = hold[2];
                    double curentDoughGr = double.Parse(hold[3]);

                    Dough holdDough = new Dough(curentFlouer, curentBaking, curentDoughGr);

                    pizza.Dough = holdDough;
                }
                else
                {
                    string curentType = hold[1];
                    double curentGr   = double.Parse(hold[2]);

                    Topping curentTopping = new Topping(curentType, curentGr);

                    pizza.Toppings.Add(curentTopping);

                    if (pizza.Toppings.Count > 10)
                    {
                        Console.WriteLine($"Number of toppings should be in range [0..10].");
                        Environment.Exit(0);
                    }
                }
            }
        }
Beispiel #2
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.");
        }
        public static void Main()
        {
            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 Toping(toppingName, toppingGrams);

                    pizza.AddToping(topping);
                }

                Console.WriteLine($"{pizza.Name} - {pizza.TotalCalories:F2} Calories.");
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            try
            {
                string pizzaName = Console.ReadLine().Split()[1];
                Pizza  pizza     = new Pizza(pizzaName);
                Dough  dough     = CreateDough();
                pizza.SetDough(dough);
                string command;

                while ((command = Console.ReadLine()) != "END")
                {
                    CreateTopping(command, pizza);
                }

                Console.WriteLine(pizza);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
            }
        }
 public Pizza(string name, Dough dough)
 {
     this.Name    = name;
     this.dough   = dough;
     this.topings = new List <Toping>();
 }
Beispiel #6
0
 public void SetDough(Dough dough)
 {
     Dough = dough;
 }