Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
    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]);
        }
    }
Ejemplo n.º 3
0
    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;
    }
Ejemplo n.º 4
0
    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();
        }
    }