private static void AddElementsToCollections(AddCollection addCollection, AddRemoveCollection addRemoveCollection, MyList myList)
        {
            List <string> data = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            AddElements(addCollection, data);
            AddElements(addRemoveCollection, data);
            AddElements(myList, data);
        }
        static void Main(string[] args)
        {
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            AddElementsToCollections(addCollection, addRemoveCollection, myList);
            RemoveElementsFromCollections(addRemoveCollection, myList);
        }
        private static void AddElements(AddCollection addCollection, AddRemoveCollection addRemoveCollection, MyList myList, string[] elementsToAdd)
        {
            foreach (var item in elementsToAdd)
            {
                addCollection.Add(item);

                addRemoveCollection.Add(item);

                myList.Add(item);
            }
        }
        public static void Main(string[] args)
        {
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            var elementsToAdd = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

            AddElements(addCollection, addRemoveCollection, myList, elementsToAdd);

            PrintAddedElements(addCollection, addRemoveCollection, myList);

            var numberOfElementsToRemove = int.Parse(Console.ReadLine());

            RemoveElements(addRemoveCollection, myList, numberOfElementsToRemove);

            PrintRemovedElements(addRemoveCollection, myList);
        }
Esempio n. 5
0
        public static void Main()
        {
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            var itemsToAdd = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var amountOfRemoveOperations = int.Parse(Console.ReadLine());

            var indexes         = new List <int>();
            var removedElements = new List <string>();

            AddItem(addCollection, itemsToAdd, indexes);
            AddItem(addRemoveCollection, itemsToAdd, indexes);
            AddItem(myList, itemsToAdd, indexes);

            RemoveItem(addRemoveCollection, amountOfRemoveOperations, removedElements);
            RemoveItem(myList, amountOfRemoveOperations, removedElements);

            PrintAddResults(indexes, itemsToAdd.Length);
            PrintRemoveResults(removedElements, amountOfRemoveOperations);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            var firstLine  = new List <int>();
            var secondLine = new List <int>();
            var thirdLine  = new List <int>();

            var fourthLine = new List <string>();
            var fifthLine  = new List <string>();

            var elementsToAdd = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

            foreach (var element in elementsToAdd)
            {
                firstLine.Add(addCollection.Add(element));
                secondLine.Add(addRemoveCollection.Add(element));
                thirdLine.Add(myList.Add(element));
            }

            var removeOperations = int.Parse(Console.ReadLine());

            for (int i = 0; i < removeOperations; i++)
            {
                fourthLine.Add(addRemoveCollection.Remove());
                fifthLine.Add(myList.Remove());
            }

            Console.WriteLine(string.Join(" ", firstLine));
            Console.WriteLine(string.Join(" ", secondLine));
            Console.WriteLine(string.Join(" ", thirdLine));
            Console.WriteLine(string.Join(" ", fourthLine));
            Console.WriteLine(string.Join(" ", fifthLine));
        }
 private static void PrintAddedElements(AddCollection addCollection, AddRemoveCollection addRemoveCollection, MyList myList)
 {
     Console.WriteLine(addCollection.CollectionAdded.ToString().TrimEnd());
     Console.WriteLine(addRemoveCollection.CollectionAdded.ToString().TrimEnd());
     Console.WriteLine(myList.CollectionAdded.ToString().TrimEnd());
 }