private void MoveToNextStation(Plane plane) { LogicStation nextStation = GetBestStation(plane); if (nextStation != null) { nextStation.EnterStation(plane); } }
/// <summary> /// Get the least busy station for a plane(depends on the route) /// </summary> /// <param name="plane">plane to choose the next route for</param> /// <returns>least busy station for the plane</returns> private LogicStation GetBestStation(IRouteable plane) { var nextStationNumbers = plane.Route.GetNextAvailableRoute(this.StationNumber); if (!nextStationNumbers.Any()) { throw new Exception("Could not be empty, if we reach the end we receive 0"); } else if (nextStationNumbers.Any(staionNum => staionNum == 0)) //if it reached the end { return(null); } else { var nextStations = GetStations(nextStationNumbers); return(LogicStation.GetBestStation(nextStations)); } }