Esempio n. 1
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine()
                             .Split(" ", StringSplitOptions.RemoveEmptyEntries);

            var    pricePerDay     = decimal.Parse(input[0]);
            var    numberOfDays    = int.Parse(input[1]);
            Season season          = (Season)Enum.Parse(typeof(Season), input[2]);
            var    priceCalculator = new PriceCalculator();

            if (input.Length == 4)
            {
                Discount discount = (Discount)Enum.Parse(typeof(Discount), input[3]);
                Console.WriteLine($"{priceCalculator.Calculate(pricePerDay, numberOfDays, season, discount):f2}");
                return;
            }

            Console.WriteLine($"{priceCalculator.Calculate(pricePerDay, numberOfDays, season, Discount.None):f2}");
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            //50.25 5 Summer VIP

            string[] input = Console.ReadLine().Split();

            decimal pricePerNigth = decimal.Parse(input[0]);

            int nigth = int.Parse(input[1]);

            Enum.TryParse(input[2], out Season season);

            Discount discount = Discount.None;

            if (input.Length > 3)
            {
                Enum.TryParse(input[3], out discount);
            }



            Console.WriteLine(PriceCalculator.Calculate(pricePerNigth, nigth, season, discount).ToString("F2"));
        }