コード例 #1
0
ファイル: Elevator.cs プロジェクト: NedM/elevator-simulator
        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
ファイル: Elevator.cs プロジェクト: NedM/elevator-simulator
        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();
            }
        }