private void SwitchBoundaries(ref Boundaries boundaries) { TravelDirection directionForCurrentBoundaries = GetBoundariesDirection(boundaries); boundaries = _floorConfiguration.GetBoundariesForDirection(directionForCurrentBoundaries == TravelDirection.Up ? TravelDirection.Down : TravelDirection.Up); }
public override bool Equals(object obj) { Boundaries objAsBoundary = (Boundaries)obj; if (objAsBoundary == null) { return(false); } return(Item1 == objAsBoundary.Item1 && Item2 == objAsBoundary.Item2); }
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); } } }
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); } } }
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()); }