示例#1
0
 public Seat(string rowName, uint number, PricingCategory pricingCategory, SeatAvailability seatAvailability, int distanceFromRowCentroid = 0)
 {
     RowName                 = rowName;
     Number                  = number;
     PricingCategory         = pricingCategory;
     SeatAvailability        = seatAvailability;
     DistanceFromRowCentroid = distanceFromRowCentroid;
 }
示例#2
0
        public bool MatchCategory(PricingCategory pricingCategory)
        {
            if (pricingCategory == PricingCategory.Mixed)
            {
                return(true);
            }

            return(PricingCategory == pricingCategory);
        }
示例#3
0
        public static IEnumerable <Seat> BuildSeats(PricingCategory pricingCategory, params string[] seats)
        {
            var result = new List <Seat>();

            foreach (var seat in seats)
            {
                result.Add(new Seat(pricingCategory, seat, SeatAvailability.Available, 0));
            }

            return(result);
        }
示例#4
0
        private static int ComputeUnitaryPrice(PricingCategory pricingCategory, PricingMatrix pricingMatrix)
        {
            switch (pricingCategory)
            {
            case PricingCategory.First:
                return(pricingMatrix.Cat1Price);

            case PricingCategory.Second:
                return(pricingMatrix.Cat2Price);

            case PricingCategory.Third:
                return(pricingMatrix.Cat3Price);

            default:
                throw new ArgumentOutOfRangeException(nameof(pricingCategory), pricingCategory, null);
            }
        }
示例#5
0
 public Seat(PricingCategory pricingCategory, string seatName, SeatAvailability seatAvailability,
             int distanceFromRowCentroid) : this(seatName, seatName[0].ToString(), uint.Parse(seatName.Substring(1)),
                                                 pricingCategory, seatAvailability, distanceFromRowCentroid)
 {
 }
示例#6
0
        private static IEnumerable <SuggestionMade> GiveMeSuggestionsFor(AuditoriumSeating auditoriumSeating, PartyRequested partyRequested, PricingCategory pricingCategory)
        {
            var foundedSuggestions = new List <SuggestionMade>();

            for (var i = 0; i < NumberOfSuggestionsPerPricingCategory; i++)
            {
                var seatOptionsSuggested = auditoriumSeating.SuggestSeatingOptionFor(new SuggestionRequest(partyRequested, pricingCategory));

                if (seatOptionsSuggested.MatchExpectation())
                {
                    // We get the new version of the Auditorium after the allocation
                    auditoriumSeating = auditoriumSeating.Allocate(seatOptionsSuggested);

                    foundedSuggestions.Add(new SuggestionMade(partyRequested, pricingCategory, seatOptionsSuggested.Seats));
                }
            }

            return(foundedSuggestions);
        }
示例#7
0
 public SuggestionRequest(PartyRequested partyRequested, PricingCategory pricingCategory)
 {
     PartyRequested  = partyRequested;
     PricingCategory = pricingCategory;
 }
 public static IEnumerable <Seat> SelectAvailableSeatsCompliant(this IEnumerable <Seat> seats, PricingCategory pricingCategory)
 {
     return(seats.Where(s => s.IsAvailable() && s.MatchCategory(pricingCategory)));
 }
示例#9
0
 public SuggestionMade(PartyRequested partyRequested, PricingCategory pricingCategory, List <Seat> seats)
 {
     PartyRequested  = partyRequested;
     PricingCategory = pricingCategory;
     _suggestedSeats = seats;
 }
示例#10
0
        public IEnumerable <string> SeatNames(PricingCategory pricingCategory)
        {
            var suggestionsMade = ForCategory[pricingCategory];

            return(suggestionsMade.Select(s => string.Join("-", s.SeatNames())));
        }
示例#11
0
 public bool MatchCategory(PricingCategory pricingCategory)
 {
     return(PricingCategory == pricingCategory);
 }