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; }
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); }
/// <summary> /// Removes cars attached to the locomotive and adds them to the line /// </summary> /// <param name="line">The line that cars will be unloaded into</param> public void UnloadAllCarsIntoLine(IIncrementableLine line) { Slots.ForEach(car => line.AddCar(car)); Slots.Clear(); }