Example #1
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.");
        }
Example #2
0
        static void Main(string[] args)
        {
            try
            {
                string input = string.Empty;

                Pizza pizza = null;
                Dough dough = null;

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

                    if (inputArgs[0] == "Pizza")
                    {
                        pizza = new Pizza(inputArgs[1]);
                    }

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

                    if (inputArgs[0] == "Topping")
                    {
                        pizza.AddTopping(new Topping(inputArgs[1], double.Parse(inputArgs[2])));
                    }
                }

                Console.WriteLine(pizza);
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message);
            }
        }
Example #3
0
 public Pizza(string name, Dough dough, List <Toppings> toppings)
 {
     this.name     = name;
     this.dough    = dough;
     this.Toppings = toppings;
 }