public PriceCalculator(decimal pricePerDay, int numberOfDays, SeasonsMultiplier season, DiscountType discountType) { this.PricePerDay = pricePerDay; this.NumberOfDays = numberOfDays; this.Season = season; this.DiscountType = discountType; TotalPrice = this.Calculate(); }
public PriceCalculator(string command) { var splitCommand = command.Split(); pricePerNight = decimal.Parse(splitCommand[0]); nights = int.Parse(splitCommand[1]); seasonMultiplier = Enum.Parse <SeasonsMultiplier>(splitCommand[2]); discount = Discounts.None; if (splitCommand.Length > 3) { discount = Enum.Parse <Discounts>(splitCommand[3]); } }
public PriceCalculator(string input) { var tokens = input .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var price = decimal.Parse(tokens[0]); var daysCount = int.Parse(tokens[1]); var seasonMultiplier = Enum.Parse <SeasonsMultiplier>(tokens[2]); Discount discountPercents = GetDiscountPercentage(tokens); this.pricePerDay = price; this.numberOfDays = daysCount; this.season = seasonMultiplier; this.discount = discountPercents; }
public ConsoleColor GetColor(SeasonsMultiplier seasonsParameter) { switch (seasonsParameter) { case SeasonsMultiplier.Autumn: return(ConsoleColor.Yellow); case SeasonsMultiplier.Spring: return(ConsoleColor.Green); case SeasonsMultiplier.Winter: return(ConsoleColor.White); case SeasonsMultiplier.Summer: return(ConsoleColor.Blue); default: throw new InvalidEnumArgumentException(); } }