public void Run() { var data = this.dataReader.Read(); // Read input from console var command = commandParser.Parse(data); // Split input from 1 to several parts decimal pricePerDay = command.PricePerDay; int days = command.Days; Season season = Enum.Parse <Season>(command.Season); Discount discount = Discount.None; if (command.Arguments.Length == 4) { discount = Enum.Parse <Discount>(command.Discount); } decimal price = PriceCalculator.CalculatePrice(pricePerDay, days, season, discount); this.dataWriter.Write(price); // Print in console }
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[] information = Console .ReadLine() .Split(" ") .ToArray(); decimal price = decimal.Parse(information[0]); int days = int.Parse(information[1]); Season season = Enum.Parse <Season>(information[2]); Discount discount = Discount.None; if (information.Length == 4) { discount = Enum.Parse <Discount>(information[3]); } decimal totalPrice = PriceCalculator.GetTotalPrice(price, days, season, discount); Console.WriteLine($"{totalPrice: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); }
public static void Main() { string[] vacationInfo = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries); decimal pricePerDay = decimal.Parse(vacationInfo[0]); int days = int.Parse(vacationInfo[1]); Season season = Enum.Parse <Season>(vacationInfo[2]); DiscountType discount = new DiscountType(); if (vacationInfo.Length > 3) { discount = Enum.Parse <DiscountType>(vacationInfo[3]); } PriceCalculator vacation = new PriceCalculator(pricePerDay, days, season, discount); decimal totalPrice = vacation.CalculatePrice(); Console.WriteLine($"{totalPrice:f2}"); }
static void Main(string[] args) { PriceCalculator priceCalculator = new PriceCalculator(Console.ReadLine()); Console.WriteLine(priceCalculator.CalculatePrice()); }
static void Main(string[] args) { var input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).ToArray(); var pricePerDay = double.Parse(input[0]); var numberOfDays = int.Parse(input[1]); Season season = Season.Autumn; switch (input[2]) { case "Autumn": { season = Season.Autumn; break; } case "Summer": { season = Season.Summer; break; } case "Spring": { season = Season.Spring; break; } case "Winter": { season = Season.Winter; break; } } Discount discount = Discount.None; if (input.Length > 3) { switch (input[3]) { case "VIP": { discount = Discount.VIP; break; } case "SecondVisit": { discount = Discount.SecondVisit; break; } } } else { discount = Discount.None; } Console.WriteLine(string.Format("{0:0.00}", PriceCalculator.GetTotalPrice(pricePerDay, numberOfDays, season, discount))); }