public TrainCompositionTests()
 {
     tree = new TrainComposition();
     tree.AttachWagonFromLeft(7);
     tree.AttachWagonFromLeft(13);
     tree.AttachWagonFromRight(20);
     tree.AttachWagonFromLeft(18);
 }
    public static void Main(string[] args)
    {
        var tree = new TrainComposition();

        tree.AttachWagonFromLeft(7);
        tree.AttachWagonFromLeft(13);
        Console.WriteLine(tree.DetachWagonFromRight()); // 7
        Console.WriteLine(tree.DetachWagonFromLeft());  // 13
    }
Example #3
0
    public static void Main(string[] args)
    {
        TrainComposition train = new TrainComposition();

        train.AttachWagonFromLeft(7);
        train.AttachWagonFromLeft(13);
        Console.WriteLine(train.DetachWagonFromRight()); // 7
        Console.WriteLine(train.DetachWagonFromLeft());  // 13
        Console.ReadLine();
    }
        public void Should_attach_and_detach_correctly()
        {
            int wagon1 = 7, wagon2 = 13;

            TrainComposition tree = new TrainComposition();

            tree.AttachWagonFromLeft(wagon1);
            tree.AttachWagonFromLeft(wagon2);

            Assert.Equal(wagon1, tree.DetachWagonFromRight()); // 7
            Assert.Equal(wagon2, tree.DetachWagonFromLeft());  // 13
        }
Example #5
0
        public void TrainComposition_DetachWagonFromRight_DetachWagonFromLeft()
        {
            // Arrange.
            TrainComposition trainComposition = new TrainComposition();

            trainComposition.AttachWagonFromLeft(7);
            trainComposition.AttachWagonFromLeft(13);

            // Act.
            int actualRight = trainComposition.DetachWagonFromRight();           // 7
            int actualLeft  = trainComposition.DetachWagonFromLeft();            // 13

            // Assert.
            Assert.AreEqual(7, actualRight);
            Assert.AreEqual(13, actualLeft);
        }
Example #6
0
        static void Main(string[] args)
        {
            #region palindrom
            /*palindrom*/
            Console.WriteLine(Program.IsPalindrome("Deleveled"));
            #endregion palindrom
            #region TextInput
            /*TextInput*/
            TextInput input = new NumericInput();
            input.Add('1');
            input.Add('a');
            input.Add('0');
            Console.WriteLine(input.GetValue());
            /*TextInput*/
            #endregion TextInput
            #region folders
            string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                         "<folder name=\"c\">" +
                         "<folder name=\"program files\">" +
                         "<folder name=\"uninstall information\" />" +
                         "</folder>" +
                         "<folder name=\"users\" />" +
                         "</folder>";

            foreach (string name in Program.FolderNames(xml, 'u'))
            {
                Console.WriteLine(name);
            }
            #endregion folders
            #region BinarySearchTree
            Console.WriteLine("BinarySearchTree");
            Node n1 = new Node(1, null, null);
            Node n3 = new Node(3, null, null);
            Node n2 = new Node(2, n1, n3);
            Console.WriteLine(Contains(n2, 3));
            #endregion
            #region TwoSum
            Tuple <int, int> indices = FindTwoSum(new List <int>()
            {
                3, 1, 5, 7, 5, 9
            }, 10);
            if (indices != null)
            {
                Console.WriteLine(indices.Item1 + " " + indices.Item2);
            }
            #endregion
            #region Mergenames
            string[] names1 = new string[] { "Ava", "Emma", "Olivia" };
            string[] names2 = new string[] { "Olivia", "Sophia", "Emma" };
            Console.WriteLine(string.Join(", ", Program.UniqueNames(names1, names2))); // should print Ava, Emma, Olivia, Sophia
            #endregion Mergenames
            #region SongList
            Song first  = new Song("Hello");
            Song second = new Song("Eye of the tiger");

            first.NextSong  = second;
            second.NextSong = first;

            Console.WriteLine(first.IsRepeatingPlaylist());
            #endregion SongList
            #region Flags
            Console.WriteLine(Access.Writer.HasFlag(Access.Delete));
            Console.WriteLine(Access.Editor.HasFlag(Access.Comment));
            Console.WriteLine(Access.Owner.HasFlag(Access.Editor));
            #endregion Flags
            #region DecoratorStream

            /* byte[] message = new byte[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x21 };
             * using (MemoryStream stream = new MemoryStream())
             * {
             *   using (DecoratorStream decoratorStream = new DecoratorStream(stream, "First line: "))
             *   {
             *       decoratorStream.Write(message, 0, message.Length);
             *       stream.Position = 0;
             *       Console.WriteLine(new StreamReader(stream).ReadLine());  //should print "First line: Hello, world!"
             *   }
             * }*/
            #endregion DecoratorStream
            #region SortedSearch
            Console.WriteLine(Program.CountNumbers(new int[] { 1, 3, 5, 7 }, 4));
            #endregion
            #region TrainComposition
            TrainComposition tree = new TrainComposition();
            tree.AttachWagonFromLeft(7);
            tree.AttachWagonFromLeft(13);
            Console.WriteLine(tree.DetachWagonFromRight()); // 7
            Console.WriteLine(tree.DetachWagonFromLeft());  // 13
            #endregion TrainComposition
            #region Path
            Path path = new Path("/a/b/c/d");   //  '/a/b/c/x'.
            path.Cd("../x/../k");
            Console.WriteLine(path.CurrentPath);
            #endregion Path
            #region GrinchAlgoritm
            var inpustring = "52201424112"; // "52250315091"; //назара //442513151 кику //55071024170 виола
            //6603260916081 Ламара

            Console.WriteLine("grinch " + GrinchAlgoritm(inpustring));
            #endregion GrinchAlgoritm
            Console.ReadKey();
        }