private static void PrintTotalPrice(string[] reservationArgs) { decimal pricePerDay = decimal.Parse(reservationArgs[0]); int days = int.Parse(reservationArgs[1]); string season = reservationArgs[2]; PriceCalculator priceCalc = new PriceCalculator(pricePerDay, days, season); if (reservationArgs.Length == 4) { string discountType = reservationArgs[3]; priceCalc.DiscountType = discountType; } decimal totalPrice = priceCalc.CalculatePrice(); Console.WriteLine($"{totalPrice:F2}"); }
static void Main(string[] args) { string[] resertvationInfo = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); decimal pricePerDay = decimal.Parse(resertvationInfo[0]); int numberOfDays = int.Parse(resertvationInfo[1]); string season = resertvationInfo[2]; string discountType = "None"; if (resertvationInfo.Length == 4) { discountType = resertvationInfo[3]; } Console.WriteLine(PriceCalculator.CalculatePrice(pricePerDay, numberOfDays, Enum.Parse <Season>(season), Enum.Parse <Discount>(discountType))); }
public void Run() { 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}"); }