Exemplo n.º 1
0
        static void Main(string[] args)
        {
            IAddableCollection <string>      addCollection      = new AddCollection <string>();
            IAddRemovableCollection <string> addRemoveColletion = new AddRemoveCollection <string>();
            IAddRemovableCollection <string> myList             = new MyList <string>();

            string[] elements = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            AddElements(elements, addCollection);
            AddElements(elements, addRemoveColletion);
            AddElements(elements, myList);

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

            RemoveElements(addRemoveColletion, itemsToRemoe);
            RemoveElements(myList, itemsToRemoe);
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            string[]            tokens              = Console.ReadLine().Split();
            AddCollection       addCollection       = new AddCollection();
            AddRemoveCollection addRemoveCollection = new AddRemoveCollection();
            MyList myList = new MyList();

            for (int i = 0; i < tokens.Length; i++)
            {
                Console.Write($"{addCollection.AddElement(tokens[i])} ");
            }

            Console.WriteLine();
            for (int i = 0; i < tokens.Length; i++)
            {
                Console.Write($"{addRemoveCollection.AddElement(tokens[i])} ");
            }

            Console.WriteLine();
            for (int i = 0; i < tokens.Length; i++)
            {
                Console.Write($"{myList.AddElement(tokens[i])} ");
            }
            Console.WriteLine();

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

            for (int i = 0; i < number; i++)
            {
                Console.Write($"{addRemoveCollection.RemoveElement()} ");
            }
            Console.WriteLine();

            for (int i = 0; i < number; i++)
            {
                Console.Write($"{myList.RemoveElement()} ");
            }
        }