Ejemplo n.º 1
0
        private static void ParseConfiguration(string configurationLine)
        {
            int[] lineNumbers = configurationLine.Split(separator).Select(int.Parse).ToArray();

            int          floorsCount = lineNumbers[configurationFloorsColumn];
            List <Floor> floors      = Enumerable.Range(1, floorsCount).Select(GlobalFactory.CreateFloor).ToList();

            GlobalCache.SetFloors(floors);

            int             elevatorsCount = lineNumbers[configurationElevatorsColumn];
            List <Elevator> elevators      = Enumerable.Range(1, elevatorsCount).Select(GlobalFactory.CreateElevator).ToList();

            GlobalCache.SetElevators(elevators);

            int          ridersCount = lineNumbers[configurationRidersColumn];
            List <Rider> riders      = Enumerable.Range(1, ridersCount).Select(GlobalFactory.CreateRider).ToList();

            GlobalCache.SetRiders(riders);

            int riderThreadsCount = lineNumbers[configurationRiderThreadsColumn];

            GlobalCache.SetRiderThreadsCount(riderThreadsCount);

            int ridersPerElevatorCount = lineNumbers[configurationRidersPerElevatorColumn];

            GlobalCache.SetRidersPerElevatorCount(ridersPerElevatorCount);
        }
Ejemplo n.º 2
0
        private static void ParseRequests(IEnumerable <string> requestLines)
        {
            var requests = new List <Request>();

            foreach (string requestLine in requestLines)
            {
                int[] requestNumbers = requestLine.Split(separator).Select(s => int.Parse(s)).ToArray();

                requests.Add(new Request(
                                 GlobalCache.Riders.First(r => r.Number == requestNumbers[requestRiderColumn]),
                                 GlobalCache.Floors.First(f => f.Number == requestNumbers[requestFloorFromColumn]),
                                 GlobalCache.Floors.First(f => f.Number == requestNumbers[requestFloorToColumn])));
            }

            GlobalCache.SetRequests(requests);
        }