private void Timer_Elapsed(object sender, ElapsedEventArgs e) { var noStopsatAnyFLoor = FloorsStopMap.All(floorstopKeyValue => floorstopKeyValue.Value == false); if (noStopsatAnyFLoor == true) { Stop(); } else { if (ElevatorDirection == Direction.Up) { if (CurrentFloorNo == Utility.TopFloorID) { Stop(); } else { MoveUp(); } } else if (ElevatorDirection == Direction.Down) { if (CurrentFloorNo == Utility.BottomFloorID) { Stop(); } else { MoveDown(); } } } }
public void Stop() { var noStopsatAnyFLoor = FloorsStopMap.All(floorstopKeyValue => floorstopKeyValue.Value == false); if (noStopsatAnyFLoor == true) { Console.WriteLine("The Elevator {0} is stopped at the floor {1}", ElevatorID, CurrentFloorNo); ElevatorDirection = Direction.NoDirection; Timer.Enabled = false; Timer.Stop(); } }