コード例 #1
0
        public virtual void RemoveTrainAt(int index)
        {
            Contract.Requires <ArgumentOutOfRangeException>(index >= 0 && index < Trains.Count());

            Contract.Assume(index < Trains.Count());

            this._trains.RemoveAt(index);
        }
コード例 #2
0
        /// <summary>
        ///     Moves a train at the specified index one step up.
        /// </summary>
        /// <param name="index">The index of the train.</param>
        public virtual void MoveTrainUpAt(int index)
        {
            Contract.Requires <ArgumentOutOfRangeException>(index >= 0 && index < Trains.Count());

            Contract.Assume(index < this._trains.Count);

            Train train = this._trains[index];

            this._trains.RemoveAt(index);
            this._trains.Insert(index - 1, train);
        }