Exemple #1
0
        public static void Main()
        {
            IAddCollection <string>       addCollection       = new AddCollection <string>();
            IAddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();
            IMyList <string> myList        = new MyList <string>();
            var addCollectionIndexes       = new StringBuilder();
            var addRemoveCOllectionIndexes = new StringBuilder();
            var myListIndexes = new StringBuilder();

            var itemsToAdd            = Console.ReadLine().Split();
            var removeOperationsCount = int.Parse(Console.ReadLine());

            foreach (var item in itemsToAdd)
            {
                addCollectionIndexes.Append($"{addCollection.Add(item)} ");
                addRemoveCOllectionIndexes.Append($"{addRemoveCollection.Add(item)} ");
                myListIndexes.Append($"{myList.Add(item)} ");
            }

            var addRemoveCollectionRemoveElements = new StringBuilder();
            var myListRemoveElements = new StringBuilder();

            for (int i = 0; i < removeOperationsCount; i++)
            {
                addRemoveCollectionRemoveElements.Append($"{addRemoveCollection.Remove()} ");
                myListRemoveElements.Append($"{myList.Remove()} ");
            }

            Console.WriteLine(addCollectionIndexes.ToString().Trim());
            Console.WriteLine(addRemoveCOllectionIndexes.ToString().Trim());
            Console.WriteLine(myListIndexes.ToString().Trim());

            Console.WriteLine(addRemoveCollectionRemoveElements.ToString().Trim());
            Console.WriteLine(myListRemoveElements.ToString().Trim());
        }
Exemple #2
0
        public void Run()
        {
            var strings             = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var amountOfRemoves     = int.Parse(Console.ReadLine());
            var addCollection       = new AddCollection();
            var addRemoveCollection = new AddRemoveCollection();
            var myList = new MyList();

            foreach (var stringItem in strings)
            {
                try
                {
                    this.Dictionary["addCollection"].Add(addCollection.Add(stringItem));
                    this.Dictionary["addRemoveCollection"].Add(addRemoveCollection.AddAtBeginning(stringItem));
                    this.Dictionary["myList"].Add(myList.AddAtBeginning(stringItem));
                }
                catch (Exception e)
                {
                }
            }

            for (int i = 0; i < amountOfRemoves; i++)
            {
                this.AddRemoveList.Add(addRemoveCollection.RemoveLastItem());
                this.MyList.Add(myList.RemoveFirstElement());
            }
        }
        public static void Main()
        {
            var inputElements = Console.ReadLine().Split(' ');
            var removeTimes   = int.Parse(Console.ReadLine());

            var addCollection       = new AddCollection <string>();
            var addRemoveCollection = new AddRemoveCollection <string>();
            var myList = new MyList <string>();

            var addCollectionAdded       = new StringBuilder();
            var addRemoveCollectionAdded = new StringBuilder();
            var myListAdded = new StringBuilder();
            var addRemoveCollectionRemoved = new StringBuilder();
            var myListRemoved = new StringBuilder();

            foreach (var inputElement in inputElements)
            {
                addCollectionAdded.Append($"{addCollection.Add(inputElement)} ");
                addRemoveCollectionAdded.Append($"{addRemoveCollection.Add(inputElement)} ");
                myListAdded.Append($"{myList.Add(inputElement)} ");
            }

            for (int i = 0; i < removeTimes; i++)
            {
                addRemoveCollectionRemoved.Append($"{addRemoveCollection.Remove()} ");
                myListRemoved.Append($"{myList.Remove()} ");
            }

            Console.WriteLine(addCollectionAdded);
            Console.WriteLine(addRemoveCollectionAdded);
            Console.WriteLine(myListAdded);
            Console.WriteLine(addRemoveCollectionRemoved);
            Console.WriteLine(myListRemoved);
        }
Exemple #4
0
        static void Main()
        {
            var elements = Console.ReadLine()
                           .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var numberOfRemoves = int.Parse(Console.ReadLine());

            var addColectionsAdds       = new StringBuilder();
            var addRemoveColectionsAdds = new StringBuilder();
            var myListAdds = new StringBuilder();
            var addRemoveColectionsRemoves = new StringBuilder();
            var myListRemoves = new StringBuilder();

            var addColection      = new AddCollection();
            var addRemoveColectio = new AddRemoveCollection();
            var myListColection   = new MyList();

            foreach (var element in elements)
            {
                addColectionsAdds.Append(addColection.Add(element) + " ");
                addRemoveColectionsAdds.Append(addRemoveColectio.Add(element) + " ");
                myListAdds.Append(myListColection.Add(element) + " ");
            }

            for (int i = 0; i < numberOfRemoves; i++)
            {
                addRemoveColectionsRemoves.Append(addRemoveColectio.Remove() + " ");
                myListRemoves.Append(myListColection.Remove() + " ");
            }

            Console.WriteLine(addColectionsAdds);
            Console.WriteLine(addRemoveColectionsAdds);
            Console.WriteLine(myListAdds);
            Console.WriteLine(addRemoveColectionsRemoves);
            Console.WriteLine(myListRemoves);
        }
Exemple #5
0
        public static void Main()
        {
            IAddCollection <string>       addCollection       = new AddCollection <string>();
            IAddRemoveCollection <string> addRemoveCollection = new AddRemoveCollection <string>();
            IMyList <string> myList = new MyList <string>();

            var elements = Console.ReadLine().Split();

            var addCollectionAddIndexes       = String.Empty;
            var addRemoveCollectionAddIndexes = String.Empty;
            var myListAddIndexes = String.Empty;

            int index;

            foreach (var element in elements)
            {
                index = addCollection.Add(element);
                addCollectionAddIndexes += index + " ";

                index = addRemoveCollection.Add(element);
                addRemoveCollectionAddIndexes += index + " ";

                index             = myList.Add(element);
                myListAddIndexes += index + " ";
            }

            Console.WriteLine(addCollectionAddIndexes.Trim());
            Console.WriteLine(addRemoveCollectionAddIndexes.Trim());
            Console.WriteLine(myListAddIndexes.Trim());

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

            var addRemoveCollectionRemoveElements = String.Empty;
            var myListAddRemoveElements           = String.Empty;

            var elementToRemove = string.Empty;

            for (int i = 0; i < countOfRemoveOperations; i++)
            {
                elementToRemove = addRemoveCollection.Remove();
                addRemoveCollectionRemoveElements += elementToRemove + " ";

                elementToRemove          = myList.Remove();
                myListAddRemoveElements += elementToRemove + " ";
            }

            Console.WriteLine(addRemoveCollectionRemoveElements.Trim());
            Console.WriteLine(myListAddRemoveElements.Trim());
        }
Exemple #6
0
 public Engine()
 {
     addCollection       = new AddCollection <string>();
     addRemoveCollection = new AddRemoveCollection <string>();
     myList = new MyList <string>();
 }