Example #1
0
        /// <summary>
        /// Moves the lift up and down.
        /// </summary>
        /// <param name="currentFloor">The current floor of the lift.</param>
        public void Move(int currentFloor)
        {
            PreviousFloor = CurrentFloor;
            CurrentFloor  = currentFloor;
            int nextFloor;

            DropPassengers(currentFloor);

            if (IsEmpty() && Floors.AreAllDelivered())
            {
                if (currentFloor > 0)
                {
                    currentFloor--;
                    nextFloor = currentFloor;
                    Move(nextFloor);
                }

                AddHistoryRecord(0);
                PrintStatus();
                return;
            }

            PickPassengers(currentFloor);

            nextFloor = NextFloor();

            PrintStatus();

            Move(nextFloor);
        }