Пример #1
0
    public static void Main()
    {
        try
        {
            var input = Console.ReadLine();

            while (input != "END")
            {
                var tokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                switch (tokens[0])
                {
                case "Dough":
                    var dough = new Dough(tokens[1], tokens[2], double.Parse(tokens[3]));
                    Console.WriteLine($"{dough.GetFlourCalories():f2}");
                    break;

                case "Topping":
                    var topping = new Topping(tokens[1], double.Parse(tokens[2]));
                    Console.WriteLine($"{topping.GetToppingCalories():f2}");
                    break;

                case "Pizza":
                    MakePizza(tokens);
                    return;
                }

                input = Console.ReadLine();
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
Пример #2
0
        public void ShouldCalculateCalories()
        {
            // Arrange
            var       topping          = new Topping(35, "veggies");
            const int expectedCalories = 56;

            // Act
            var caloriesResult = topping.GetToppingCalories();

            // Assert
            Assert.AreEqual(expectedCalories, caloriesResult);
        }