Exemple #1
0
        public static void Main()
        {
            try
            {
                Pizza pizza = new Pizza(Console.ReadLine().Split()[1]);

                string input = Console.ReadLine();

                while (input != "END")
                {
                    string[] args = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                    if (args[0] == "Dough")
                    {
                        var dough = new Dough(args[1], args[2], decimal.Parse(args[3]));

                        pizza.Dough = dough;
                    }
                    else if (args[0] == "Topping")
                    {
                        var topping = new Topping(args[1], decimal.Parse(args[2]));

                        pizza.AddTopping(topping);
                    }

                    input = Console.ReadLine();
                }

                Console.WriteLine(pizza);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        private static void CalculatePizzaCalories()
        {
            var inpit = Console.ReadLine().Split();

            try
            {
                while (inpit[0] != "END")
                {
                    switch (inpit[0].ToLower())
                    {
                    case "pizza":
                        var pizza = SetPizza(inpit[1], int.Parse(inpit[2]));
                        Console.WriteLine(pizza.GetTotalCalories());
                        break;

                    case "dough":
                        var douugh = new Dough(inpit[1], inpit[2], int.Parse(inpit[3]));
                        Console.WriteLine($"{douugh.GetCalories():F2}");
                        break;

                    case "topping":
                        var toppint = new Topping(inpit[1], int.Parse(inpit[2]));
                        Console.WriteLine($"{toppint.GetCalories():F2}");
                        break;

                    default:
                        break;
                    }

                    inpit = Console.ReadLine().Split();
                }
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #3
0
 public Pizza(string name, Dough dough)
 {
     this.Name     = name;
     this.dough    = dough;
     this.toppings = new List <Topping>();
 }
Exemple #4
0
 public Pizza(string name, Dough dough, List <Topping> toppings)
 {
     this.Name     = name;
     this.Toppings = toppings;
     this.Dough    = dough;
 }
 public Pizza(string name, int numberOfToppings, Dough dough)
     : this(name, numberOfToppings)
 {
     this.dough = dough;
 }
Exemple #6
0
 public Pizza(string name)
 {
     this.Name    = name;
     this.dough   = null;
     this.topings = new List <Topping>();
 }