public void SizeOfListMustBeEqualToTheNumberOfItemsAdded()
        {
            myList.AddElement(5);
            myList.AddElement(78);

            Assert.AreEqual(2, myList.SizeOfList());
        }
        public void AddElementAndAddUniqueElementToListShouldWork()
        {
            list.AddElement("abc");
            list.AddUniqueElementToList("abc");
            list.AddElement("abc");

            Assert.AreEqual(2, list.SizeOfList());
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            AddCollection <string> addCollection = new AddCollection <string>();

            AddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();

            MyList <string> myList = new MyList <string>();

            string[] elements = Console.ReadLine().Split();
            int      removeOperationsCount = int.Parse(Console.ReadLine());

            int[,] indexes = new int[3, elements.Length];
            for (int col = 0; col < elements.Length; col++)
            {
                string element = elements[col];
                indexes[0, col] = addCollection.AddElement(element);
                indexes[1, col] = addRemoveCollection.AddElement(element);
                indexes[2, col] = myList.AddElement(element);
            }
            string[,] stringRemoveElements = new string[2, removeOperationsCount];
            for (int col = 0; col < removeOperationsCount; col++)
            {
                stringRemoveElements[0, col] = addRemoveCollection.Remove();
                stringRemoveElements[1, col] = myList.Remove();
            }

            PrintIndexes(indexes);
            PrintRemovedElements(stringRemoveElements);

            //foreach (var element in elements)
            //{
            //    Console.Write(addCollection.AddElement(element) + " ");
            //    addRemoveCollection.AddElement(element);
            //}
            //Console.WriteLine();
            //foreach (var element in elements)
            //{
            //    Console.Write(addRemoveCollection.AddElement(element) + " ");
            //}
            //Console.WriteLine();
            //foreach (var element in elements)
            //{
            //    Console.Write(myList.AddElement(element) + " ");
            //}
            //Console.WriteLine();
            //for (int i = 0; i < removeOperationsCount; i++)
            //{
            //    Console.Write(addRemoveCollection.Remove() + " ");
            //}
            //Console.WriteLine();
            //for (int i = 0; i < removeOperationsCount; i++)
            //{
            //    Console.Write(myList.Remove() + " ");
            //}
        }
        public void Run()
        {
            string[] elementsToAdd = Console.ReadLine()
                                     .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                     .ToArray();

            AddCollection       addCollection       = new AddCollection();
            AddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            MyList myList = new MyList();

            List <int> firstIndexes  = new List <int>();
            List <int> secondIndexes = new List <int>();
            List <int> thirdIndexes  = new List <int>();

            foreach (string element in elementsToAdd)
            {
                int first = addCollection.AddElement(element);
                firstIndexes.Add(first);

                int second = addRemoveCollection.AddElement(element);
                secondIndexes.Add(second);

                int third = myList.AddElement(element);
                thirdIndexes.Add(third);
            }

            Console.WriteLine(string.Join(" ", firstIndexes));
            Console.WriteLine(string.Join(" ", secondIndexes));
            Console.WriteLine(string.Join(" ", thirdIndexes));

            List <string> secondElements = new List <string>();
            List <string> thirdElements  = new List <string>();

            int numberOfCommands = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfCommands; i++)
            {
                string secondElement = addRemoveCollection.RemoveElement();
                secondElements.Add(secondElement);

                string thirdElement = myList.RemoveElement();
                thirdElements.Add(thirdElement);
            }

            Console.WriteLine(string.Join(" ", secondElements));
            Console.WriteLine(string.Join(" ", thirdElements));
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            MyList<int> list = new MyList<int>(5);
            list.AddElement(1);
            list.AddElement(2);
            list.AddElement(3);
            list.AddElement(4);
            list.AddElement(5);

            //Task 5: 
            //list.AddElementAtIndex(3, 10);
            //list.RemoveElementAtIndex(4);
            //list.Clear();

            //Task 6: Showing that if the length of the array is not enough- it expands.
            for (int i = 0; i < 100; i++)
            {
                list.AddElement(i);
            }

            //Task 7: Returning Min and Max Value
            Console.WriteLine(list.Min());
            Console.WriteLine(list.Max());
        }