Esempio n. 1
0
        /*Method to move this elevator floor by floor
         * depending on the current direction.CurrentFloor increased by 1 if
         * Direction is UP and decrease by 1 if Direction is DOWN, returns immidiatly
         * if Direction is STOP
         *
         * param int floor - next floor to go.
         */
        public void GoToFloor(int floor)
        {
            this.CurrentFloor = floor;
            ReachedFloor?.Invoke(floor);
            switch (CurrentDirection)
            {
            case Direction.UP:
                floor++;
                break;

            case Direction.DOWN:
                floor--;
                break;

            case Direction.STOP:
                return;
            }
            //recursion, repeats until it stops
            GoToFloor(floor);
        }
Esempio n. 2
0
 public void GoToFloor(int floor)
 {
     CurrentFloor = floor;
     ReachedFloor.Invoke(floor);
 }