예제 #1
0
        private void ServiceFloorRequestInUpwardDirection()
        {
            FloorRequest nextRequestAbove = GetNextRequestAbove();

            if (null == nextRequestAbove)
            {
                return;
            }

            if (nextRequestAbove.Floor != CurrentFloor)
            {
                Ascend();
                return;
            }

            if (nextRequestAbove.Direction != Direction.Down)
            {
                Floor stopFloor = nextRequestAbove.Floor;

                _upDirectionQueue.Remove(nextRequestAbove);

                StopAtFloor(stopFloor);
            }

            if (ShouldReverseDirections())
            {
                ReverseDirectionOfTravel();
            }
        }
예제 #2
0
        private void ServiceFloorRequestsInDownwardDirection()
        {
            FloorRequest nextRequestBelow = GetNextRequestBelow();

            if (null == nextRequestBelow)
            {
                return;
            }

            if (nextRequestBelow.Floor != CurrentFloor)
            {
                Descend();
                return;
            }

            if (nextRequestBelow.Direction != Direction.Up)
            {
                Floor stopFloor = nextRequestBelow.Floor;

                _downDirectionQueue.Remove(nextRequestBelow);

                StopAtFloor(stopFloor);
            }

            if (ShouldReverseDirections())
            {
                ReverseDirectionOfTravel();
            }
        }