示例#1
0
        private List<string> BuildDestinationList(int BusLine, string CurrentBusStop,Route Route)
        {
            List<string> Destinations = new List<string>();

            // add remaining bus stops after route destination include destination
            string[] AllBusStops = CityMap.Lines[BusLine];
            int DestinationPosition = Array.IndexOf(AllBusStops, Route.BusStopA == CurrentBusStop ? Route.BusStopB : Route.BusStopA);
            var RemainStops = AllBusStops.Skip(DestinationPosition);

            Destinations.AddRange(RemainStops);

            return Destinations;
        }
示例#2
0
 public static bool Navigate(string From,string To,out Route Result)
 {
     Result = new Route();
     var result = from r in Routes
                  where (r.BusStopA == From && r.BusStopB == To) || (r.BusStopA == To && r.BusStopB == From)
                  select r;
     if (result.Count() == 0)
         return false;
     Result = result.First();
     return true;
 }
示例#3
0
        private bool CheckSkippedBusStopsGetOn(int BusLine,string CurrentBusStop,string Skipped, Route Route)
        {
            string[] AllBusStops = CityMap.Lines[BusLine];
            int DestinationPosition = Array.IndexOf(AllBusStops, Route.BusStopA == CurrentBusStop ? Route.BusStopB : Route.BusStopA) + 1;
            string[] RemainStops = AllBusStops.Skip(DestinationPosition).ToArray();

            bool GetOn = false;
            BusStop SkippedBusStop = CityMap.BusStops[Skipped];
            foreach(var s in RemainStops)
            {
                if (SkippedBusStop.Passengers.Keys.ToList().Exists(x => x == s))
                {
                    if (SkippedBusStop.Passengers[s].Count != 0)
                        GetOn = true;
                }
            }

            return GetOn;
        }
示例#4
0
 private string[] CheckSkippedBusStops(int BusLine,string CurrentBusStop, Route Route)
 {
     string[] AllBusStops = CityMap.Lines[BusLine];
     int CurrentPosition = Array.IndexOf(AllBusStops, CurrentBusStop)+1;
     int DestinationPosition = Array.IndexOf(AllBusStops, Route.BusStopA == CurrentBusStop ? Route.BusStopB : Route.BusStopA)+1;
     int Count = DestinationPosition - CurrentPosition -1;
     string[] SkippedStops = AllBusStops.Skip(CurrentPosition).Take(Count).ToArray();
     return SkippedStops;
 }