public static void Main() { var arr = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var pricePerDay = decimal.Parse(arr[0]); var numberOfDays = int.Parse(arr[1]); var season = Enum.Parse <Season>(arr[2]); var discountType = DiscountType.None; if (arr.Length > 3) { discountType = Enum.Parse <DiscountType>(arr[3]); } var calc = new PriceCalculator(pricePerDay, numberOfDays, season, discountType); Console.WriteLine($"{calc.Calculate():F2}"); }
static void Main(string[] args) { string[] command = Console.ReadLine().Split(); decimal pricePerDay = decimal.Parse(command[0]); int numberOfDays = int.Parse(command[1]); Season seasons = (Season)Enum.Parse(typeof(Season), command[2]); Discount discount = Discount.None; if (command.Length > 3) { discount = (Discount)Enum.Parse(typeof(Discount), command[3]); } PriceCalculator priceCalc = new PriceCalculator(); string total = priceCalc.Calculate(pricePerDay, numberOfDays, seasons, discount); Console.WriteLine(total); }
static void Main() { string input = Console.ReadLine(); var tokens = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); decimal pricePerDay = decimal.Parse(tokens[0]); int days = int.Parse(tokens[1]); string season = tokens[2]; string discountType = "None"; if (tokens.Length == 4) { discountType = tokens[3]; } var customSeason = (Season)Enum.Parse(typeof(Season), season); var customDiscount = (Discount)Enum.Parse(typeof(Discount), discountType); var calculator = new PriceCalculator(days, pricePerDay, customSeason, customDiscount); Console.WriteLine($"{calculator.Calculate():f2}"); }
static void Main(string[] args) { string[] input = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries) .ToArray(); 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(); } PriceCalculator priceCalculator = new PriceCalculator(); var output = priceCalculator.Calculate(pricePerDay, numberOfDays, Enum.Parse <Season>(season), Enum.Parse <Discount>(discountType)); Console.WriteLine(output); }