Beispiel #1
0
        private static MetroLane[] GetStartingLanes(string startingStation, MetroLane[] lanes)
        {
            MetroLane[] foundLanes = new MetroLane[lanes.Length];
            int         k          = 0;

            foreach (MetroLane lane in lanes)
            {
                if (lane.ContainsStation(startingStation))
                {
                    foundLanes[k++] = lane;
                }
            }

            return(foundLanes);
        }
Beispiel #2
0
        public string GetTransferStation(MetroLane otherLane)
        {
            int i = 0;

            while (i < stations.Length && !otherLane.ContainsStation(stations[i]))
            {
                i++;
            }

            string transferStation = null;

            if (i < stations.Length)
            {
                transferStation = stations[i];
            }
            return(transferStation);
        }
Beispiel #3
0
        private static MetroLane[] GetLanesFromFile(string fileName)
        {
            MetroLane[]  lanes  = new MetroLane[3];
            StreamReader reader = new StreamReader("./" + fileName);
            int          i      = 0;

            while (!reader.EndOfStream)
            {
                string   line             = reader.ReadLine();
                string[] split            = line.Split(';');
                int      numberOfStations = int.Parse(split[0]);
                string[] lane             = new string[numberOfStations];
                for (int j = 1; j < split.Length; j++)
                {
                    lane[j - 1] = split[j];
                }

                lanes[i++] = new MetroLane(lane);
            }
            reader.Close();
            reader.Dispose();

            return(lanes);
        }