Example #1
0
        public void MoveElevator(IMotor motor, ICabin cabin, IFloor floor)
        {
            DoorState tempstate = cabin.GetDoorState();

            if (tempstate == DoorState.open)
            {
                _timerSensor.Stop();
                cabin.UpdateDoorState(DoorState.close);
                floor.UpdateDoorState(DoorState.close);
            }
            if (_requestManager.HasAnyRequest())
            {
                _elevatorDirection = _directionManager.EnsureDirection(_currentLevel, _elevatorDirection, _requestManager);
                _motionSensor.MoveCabin(motor, cabin, _elevatorDirection);
                _currentLevel = floor.GetLevel(cabin, _elevatorDirection, _currentLevel);
                cabin.ShowLevel(_currentLevel);
                floor.ShowLevel(_currentLevel);
                if (_requestManager.FloorHaveRequest(_currentLevel, _elevatorDirection))
                {
                    cabin.changeColorCabinButton(_currentLevel.ToString());
                    cabin.UpdateDoorState(DoorState.open);
                    _levelSensor.NotifyArrival(_txtElevator, _currentLevel);
                }
            }
        }
 public Client1(IAutoFactory factory_)
 {
     body_    = factory_.CreateIBody();
     cabin_   = factory_.CreateICabin();
     chassis_ = factory_.CreateIChassis();
     engine_  = factory_.CreateIEngine();
 }
Example #3
0
 public Elevator(TextBox txtElevator)
 {
     _txtElevator = txtElevator;
     _cabin       = new Cabin(txtElevator, 0);
     _floor       = new Floor(txtElevator);
     _director    = new Director(txtElevator);
     _motor       = new Motor(txtElevator);
 }
Example #4
0
 private int  GoDown(ICabin cabin, int cabinHeight, int currentFloor)
 {
     if (cabinHeight < 0)
     {
         cabin.UpdateHeight(getfloorheigth(currentFloor));
         return(currentFloor = currentFloor - 1);
     }
     return(currentFloor);
 }
Example #5
0
 private int GoUp(ICabin cabin, int heightFloor, int cabinHeight, int currentFloor)
 {
     if (cabinHeight > heightFloor)
     {
         cabin.UpdateHeight(0);
         return(currentFloor = currentFloor + 1);
     }
     return(currentFloor);
 }
Example #6
0
        public int GetLevel(ICabin cabin, Direction elevatorDirecion, int currentFloor)
        {
            int cabinHeight = cabin.GetHeight();
            int heightFloor = getfloorheigth(currentFloor);

            if (elevatorDirecion == Direction.up)
            {
                currentFloor = GoUp(cabin, heightFloor, cabinHeight, currentFloor);
            }
            else
            {
                currentFloor = GoDown(cabin, cabinHeight, currentFloor);
            }
            return(currentFloor);
        }
 public Car(ICarFactory factory)
 {
     _body  = factory.CreateBody();
     _motor = factory.CreateMotor();
     _cabin = factory.CreateCabin();
 }