Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(" ");

            decimal PricePerDay = decimal.Parse(input[0]);
            int     days        = int.Parse(input[1]);
            string  season      = input[2];
            decimal price       = 0;

            if (input.Length == 4)
            {
                price = PriceCalculator.CalculatePrice(PricePerDay, days, Enum.Parse <Season>(season), Enum.Parse <Discount>(input[3]));
            }
            else
            {
                price = PriceCalculator.CalculatePrice(PricePerDay, days, Enum.Parse <Season>(season), Discount.NoDiscount);
            }
            Console.WriteLine($"{price:f2}");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var items = Console.ReadLine()
                        .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                        .ToArray();

            var pricePerDay  = decimal.Parse(items[0]);
            var numberOfDays = int.Parse(items[1]);
            var season       = (Season)Enum.Parse(typeof(Season), items[2]);
            var discountType = DiscountType.None;

            if (items.Length == 4)
            {
                discountType = (DiscountType)Enum.Parse(typeof(DiscountType), items[3]);
            }

            PriceCalculator calculator = new PriceCalculator(pricePerDay, numberOfDays, season, discountType);

            Console.WriteLine($"{calculator.CalculatePrice():F2}");
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine()
                             .Split(' ', StringSplitOptions.RemoveEmptyEntries);

            decimal pricePerDay  = decimal.Parse(input[0]);
            int     numberOfDays = int.Parse(input[1]);
            string  season       = input[2].ToLower();
            string  discountType = "none";

            if (input.Length > 3)
            {
                discountType = input[3].ToLower();
            }

            decimal totalPrice = PriceCalculator.CalculatePrice(pricePerDay,
                                                                numberOfDays,
                                                                Enum.Parse <Season>(season),
                                                                Enum.Parse <Discount>(discountType));

            Console.WriteLine($"{totalPrice:f2}");
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var reservationInfo = Console.ReadLine().Split().ToArray();

            Console.WriteLine($"{PriceCalculator.GetTotalPrice(reservationInfo):F2}");
        }