示例#1
0
        private void SwitchBoundaries(ref Boundaries boundaries)
        {
            TravelDirection directionForCurrentBoundaries = GetBoundariesDirection(boundaries);

            boundaries = _floorConfiguration.GetBoundariesForDirection(directionForCurrentBoundaries == TravelDirection.Up
                            ? TravelDirection.Down
                            : TravelDirection.Up);
        }
示例#2
0
        public override bool Equals(object obj)
        {
            Boundaries objAsBoundary = (Boundaries)obj;

            if (objAsBoundary == null)
            {
                return(false);
            }
            return(Item1 == objAsBoundary.Item1 &&
                   Item2 == objAsBoundary.Item2);
        }
示例#3
0
        private void ProcessSummonsRequestSegment(IList <SummonInformation> requests, TravelDirection direction, Boundaries boundaries, bool handleExtremum)
        {
            IList <SummonInformation> selectedSummons = GetAllSummonsForDirectionOfTravelInBoundaries(requests, direction, boundaries).ToList();

            if (handleExtremum)
            {
                HandleSummonForBoundaries(requests, direction, boundaries, selectedSummons);
            }

            foreach (var summon in selectedSummons)
            {
                if (_executionPlan.CanAddToExecutionPlan(summon))
                {
                    _executionPlan.Add(summon);
                }
            }
        }
示例#4
0
 private void HandleSummonForBoundaries(IList <SummonInformation> requests, TravelDirection direction, Boundaries boundaries, IList <SummonInformation> selectedSummons)
 {
     foreach (var summon in requests)
     {
         if (boundaries.IsExtremum(direction, summon.SummonFloor))
         {
             selectedSummons.Add(summon);
         }
     }
 }
示例#5
0
        private IList <SummonInformation> GetAllSummonsForDirectionOfTravelInBoundaries(IList <SummonInformation> requests, TravelDirection direction, Boundaries boundaries)
        {
            var selectedSummons = requests.Where(summon =>
            {
                return(!boundaries.IsExtremum(direction, summon.SummonFloor) &&
                       IsSummonRequestInBoundariesAndMatchingDirection(summon, direction, boundaries));
            }).ToList();

            return(direction == TravelDirection.Up
                        ? selectedSummons.OrderBy(summon => summon.SummonFloor).ToList()
                        : selectedSummons.OrderByDescending(summon => summon.SummonFloor).ToList());
        }