Esempio n. 1
0
        public void Operate(EnumElevatorDirection direction)
        {
            _direction = direction;
            switch (_direction)
            {
            case EnumElevatorDirection.Up:
                if (_upQueue.Contains(_currentFloor))
                {
                    _upQueue.Remove(_currentFloor);
                    _status = EnumElevatorStatus.Stopped;
                }
                else
                {
                    _status = EnumElevatorStatus.Moving;
                }

                break;

            case EnumElevatorDirection.Down:
                if (_downQueue.Contains(_currentFloor))
                {
                    _downQueue.Remove(_currentFloor);
                    _status = EnumElevatorStatus.Stopped;
                }
                else
                {
                    _status = EnumElevatorStatus.Moving;
                }
                break;

            case EnumElevatorDirection.Idle:
                _status = EnumElevatorStatus.Idle;
                break;
            }
        }
Esempio n. 2
0
 public void MoveUp()
 {
     if (this._currentFloor < _maxFloor)
     {
         this._currentFloor += 1;
         _status             = EnumElevatorStatus.MovingUp;
     }
     else
     {
         _status = EnumElevatorStatus.LastFloor;
     }
 }
Esempio n. 3
0
 public void MoveDown()
 {
     if (_currentFloor > _minFloor)
     {
         this._currentFloor -= 1;
         _status             = EnumElevatorStatus.MovingDown;
     }
     else
     {
         _status = EnumElevatorStatus.GroundFloor;
     }
 }