Exemple #1
0
        static void Main(string[] args)
        {
            RailRoadData railroadData = null;

            var parser = new Parser();

            try
            {
                Console.WriteLine("Введите путь к файлу с конфигурацией: ");
                var fileName = Console.ReadLine();
                railroadData = parser.ReadAndFill(fileName);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            MapManager map = new MapManager(railroadData);

            string result = map.CheckMap();

            Console.WriteLine(result);

            Console.ReadLine();
        }
        public MapManager(RailRoadData data)
        {
            foreach (var st in data.Stations)
            {
                this.dictOfStations.Add(st.Id, new Station(st.Id));
            }

            foreach (var pt in data.Paths)
            {
                var path = new Path(pt.Length);

                this.dictOfStations[pt.FirstStationId].Paths.Add(pt.SecondStationId, path);
                this.dictOfStations[pt.SecondStationId].Paths.Add(pt.FirstStationId, path);
            }

            foreach (var tr in data.Trains)
            {
                var trainStations = tr.Route.Select(stationId => this.dictOfStations[stationId]);
                var train         = new Train(trainStations);
                this.trains.Add(train);
            }
        }