public static void Main()
    {
        //92/100
        try
        {
            var pizzaInfo = Console.ReadLine().Split();
            var pizzaName = pizzaInfo[1];

            var doughInfo = Console.ReadLine().Split();

            Dough dough = new Dough(doughInfo[1], doughInfo[2], double.Parse(doughInfo[3]));
            Pizza pizza = new Pizza(pizzaName, dough);

            var toppingInfo = Console.ReadLine();
            while (!toppingInfo.Equals("END"))
            {
                var args = toppingInfo.Split();

                var topping = new Topping(args[1], double.Parse(args[2]));
                pizza.AddTopping(topping);

                toppingInfo = Console.ReadLine();
            }

            Console.WriteLine($"{pizza.Name} - {pizza.CalcTotalCalories():F2} Calories.");
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
Esempio n. 2
0
    static void Main(string[] args)
    {
        try
        {
            var   pizzaInfo     = Console.ReadLine().Split();
            var   doughInfo     = Console.ReadLine().Split();
            Dough currentDought = new Dough(flourType: doughInfo[1], bakingTechnique: doughInfo[2], weight: double.Parse(doughInfo[3]));

            Pizza currentPizza = new Pizza(name: pizzaInfo[1], dough: currentDought);
            var   toppingInfo  = new string[3];
            while ((toppingInfo = Console.ReadLine().Split())[0] != "END")
            {
                Topping currentTopping = new Topping(type: toppingInfo[1], weight: double.Parse(toppingInfo[2]));
                currentPizza.AddToppings(currentTopping);
            }

            Console.WriteLine($"{currentPizza.Name} - {currentPizza.CalcTotalCalories():f2} Calories.");
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
Esempio n. 3
0
    public static void Main()
    {
        string input        = string.Empty;
        Pizza  currentPizza = null;

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

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

                    if (currentPizza == null)
                    {
                        Console.WriteLine($"{dough.CalcDoughCalories():f2}");
                    }
                    else
                    {
                        currentPizza.Dough = dough;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return;
                }
            }
            else if (args[0].Equals("Topping"))
            {
                try
                {
                    Topping topping = new Topping(args[1], double.Parse(args[2]));

                    if (currentPizza == null)
                    {
                        Console.WriteLine($"{topping.CalcToppingCalories():f2}");
                    }
                    else
                    {
                        currentPizza.AddToping(topping);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return;
                }
            }
            else if (args[0].Equals("Pizza"))
            {
                try
                {
                    Pizza pizza = new Pizza(args[1]);
                    currentPizza = pizza;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    return;
                }
            }
        }

        if (currentPizza != null)
        {
            Console.WriteLine($"{currentPizza.Name} - {currentPizza.CalcTotalCalories():f2} Calories.");
        }
    }
Esempio n. 4
0
 private void PrintOutput(IWriter writer)
 {
     writer.WriteLine($"{pizza.Name} - {pizza.CalcTotalCalories():F2} Calories.");
 }