コード例 #1
0
ファイル: Yardmaster.cs プロジェクト: hperantunes/cn-railway
        private IMovement MoveConvoy(IYardLocomotive locomotive, ILinesMap map, IDecrementableLine origin, IIncrementableLine destination, int amount)
        {
            locomotive.LoadCarsFromLine(origin, amount);
            var movement = new Movement(origin, destination, locomotive.Cars.AsEnumerable<INamed>().ToList());
            map.UpdateDepths(origin as ISortingLine, -movement.Cars.Count());

            locomotive.UnloadAllCarsIntoLine(destination);
            map.UpdateDepths(destination as ISortingLine, movement.Cars.Count());

            return movement;
        }
コード例 #2
0
ファイル: Yardmaster.cs プロジェクト: hperantunes/cn-railway
        private IMovement MoveConvoy(IYardLocomotive locomotive, ILinesMap map, IDecrementableLine origin, IIncrementableLine destination, int amount)
        {
            locomotive.LoadCarsFromLine(origin, amount);
            var movement = new Movement(origin, destination, locomotive.Cars.AsEnumerable <INamed>().ToList());

            map.UpdateDepths(origin as ISortingLine, -movement.Cars.Count());

            locomotive.UnloadAllCarsIntoLine(destination);
            map.UpdateDepths(destination as ISortingLine, movement.Cars.Count());

            return(movement);
        }
コード例 #3
0
ファイル: Yardmaster.cs プロジェクト: hperantunes/cn-railway
        /// <summary>
        /// Assemble trains bound to a given destination into the train line
        /// </summary>
        /// <param name="map">A map to provide assemblage instructions</param>
        /// <returns>
        /// A collection of all movements that were executed when
        /// assembling the train
        /// </returns>
        public IEnumerable<IMovement> AssembleTrain(ILinesMap map)
        {
            var movements = new List<IMovement>();
            Tuple<IDecrementableLine, IIncrementableLine, int> directions;
            while ((directions = map.GetInstruction()) != null)
            {
                var movement = MoveConvoy(YardLocomotive, map, directions.Item1, directions.Item2, directions.Item3);
                movements.Add(movement);
            }

            return movements;
        }
コード例 #4
0
ファイル: Yardmaster.cs プロジェクト: hperantunes/cn-railway
        /// <summary>
        /// Assemble trains bound to a given destination into the train line
        /// </summary>
        /// <param name="map">A map to provide assemblage instructions</param>
        /// <returns>
        /// A collection of all movements that were executed when
        /// assembling the train
        /// </returns>
        public IEnumerable <IMovement> AssembleTrain(ILinesMap map)
        {
            var movements = new List <IMovement>();
            Tuple <IDecrementableLine, IIncrementableLine, int> directions;

            while ((directions = map.GetInstruction()) != null)
            {
                var movement = MoveConvoy(YardLocomotive, map, directions.Item1, directions.Item2, directions.Item3);
                movements.Add(movement);
            }

            return(movements);
        }