예제 #1
0
        public void DisplayTrain()
        {
            builder = new StringBuilder();
            builder.Append("ENGINE=>");
            Coach <T> current = Engine;

            while (current.Next != null)
            {
                current = current.Next;
                builder.Append(current.Value);
                builder.Append("=>");
            }
            builder.Append("CLOSE");
            Console.WriteLine(builder.ToString());
        }
예제 #2
0
        private Coach <T> FindNode(T value)
        {
            Coach <T> current = Engine;

            while (current != null)
            {
                if (current.Value == null)
                {
                    current = current.Next;
                    continue;
                }

                if (current.Value.ToString().Equals(value.ToString()))
                {
                    return(current);
                }
                current = current.Next;
            }

            return(null);
        }
예제 #3
0
 public Train()
 {
     Engine = new Coach <T>(null);
 }
예제 #4
0
 public Coach(T value)
 {
     Value = value ?? default;
     Next  = null;
 }