예제 #1
0
        private static void Main(string[] args)
        {
            var   tokens = Console.ReadLine().Split(new[] { ' ' });
            Pizza myPizza;

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

            tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            try
            {
                var myDough = new Dough(tokens[1], tokens[2], double.Parse(tokens[3]));
                myPizza.Dough = myDough;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    var myTopping = new Topping(tokens[1], double.Parse(tokens[2]));
                    myPizza.AddTopping(myTopping);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return;
                }
            }

            Console.WriteLine($"{myPizza.Name} - {myPizza.Calories():f2} Calories.");
        }
예제 #2
0
        public static void Main()
        {
            string[] pizzaProps = Console.ReadLine().Split();
            string   pizzaName  = pizzaProps[1];

            string[] doughProps       = Console.ReadLine().Split();
            string   floor            = doughProps[1];
            string   backingTechnique = doughProps[2];
            double   doughWeight      = double.Parse(doughProps[3]);

            try
            {
                Dough dough = new Dough(floor, backingTechnique, doughWeight);

                Pizza pizza = new Pizza(pizzaName, dough);

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

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

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

                    Topping topping = new Topping(toppingType, toppingWeight);

                    pizza.AddToppint(topping);
                }

                Console.WriteLine($"{pizza.Name} - {pizza.CalculateCalories():f2} Calories.");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            try
            {
                var pizzaDetails = Console.ReadLine().Split(" ");
                var pizzaName    = pizzaDetails[1];
                var doughDetails = Console.ReadLine().Split(" ");

                var flourType       = doughDetails[1];
                var bakingTechnique = doughDetails[2];
                var doughWweight    = int.Parse(doughDetails[3]);

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

                while (true)
                {
                    var toppingDetails = Console.ReadLine().Split(" ");

                    if (toppingDetails[0] == "END")
                    {
                        break;
                    }

                    var type          = toppingDetails[1];
                    var toppingWeight = int.Parse(toppingDetails[2]);

                    Topping topping = new Topping(type, toppingWeight);
                    pizza.AddTopping(topping);
                }
                Console.WriteLine($"{pizza.Name} - {pizza.GetCalories():F2} Calories.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #4
0
 public Pizza(string name, Dough dough)
 {
     this.Name     = name;
     this.Dough    = dough;
     this.toppings = new List <Topping>();
 }