public int DetachWagonFromRight() { TrainNode tmp; if (rightMost != null) { tmp = rightMost; rightMost = rightMost.LeftTrain; var tmpValue = tmp.Value; return(tmpValue); } else { return(0); } }
public int DetachWagonFromLeft() { TrainNode tmp; if (leftMost != null) { tmp = leftMost; leftMost = leftMost.RightTrain; var tmpValue = tmp.Value; return(tmpValue); } else { return(0); } }
/// <summary> /// Detaches the wagon from right. /// </summary> /// <returns></returns> public int DetachWagonFromRight() { TrainNode tmp; if (Rightmost != null) { tmp = Rightmost; Rightmost = Rightmost.LeftTrain; int tmpValue = tmp.Value; return(tmpValue); } else { return(0); } }
/// <summary> /// Attaches the wagon from right. /// </summary> /// <param name="wagonId">The wagon identifier.</param> public void AttachWagonFromRight(int wagonId) { TrainNode tmp = new TrainNode(wagonId); if (Rightmost != null) { Rightmost.SetRightTrain(tmp); tmp.SetLeftTrain(Rightmost); Rightmost = tmp; } else { Leftmost = tmp; Rightmost = tmp; } }
public void AttachWagonFromRight(int wagonId) { var tmp = new TrainNode(wagonId); if (rightMost != null) { // Trains in composition rightMost.SetRightTrain(tmp); tmp.SetLeftTrain(rightMost); rightMost = tmp; } else { leftMost = tmp; rightMost = tmp; } }
public TrainComposition() { leftMost = null; rightMost = null; }
public void SetLeftTrain(TrainNode left) { this.LeftTrain = left; }
public void SetRightTrain(TrainNode right) { this.RightTrain = right; }
public TrainNode(int value) { this.Value = value; this.LeftTrain = null; this.RightTrain = null; }
/// <summary> /// Sets the right train. /// </summary> /// <param name="right">The right.</param> public void SetRightTrain(TrainNode right) { RigthTrain = right; }
/// <summary> /// Initializes a new instance of the <see cref="TrainNode"/> class. /// </summary> /// <param name="value">The value.</param> public TrainNode(int value) { Value = value; LeftTrain = null; RigthTrain = null; }