Example #1
0
    static void Main(string[] args)
    {
        string[] input          = Console.ReadLine().Split(' ');
        int      countOfRemoves = int.Parse(Console.ReadLine());


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

        foreach (var item in input)
        {
            addCollection.AddItem(item);
            addRemoveCollection.AddItem(item);
            myList.AddItem(item);
        }

        for (int i = 0; i < countOfRemoves; i++)
        {
            addRemoveCollection.RemoveItem();
            myList.RemoveItem();
        }

        Console.WriteLine(string.Join(" ", addCollection.CollectionAdds));
        Console.WriteLine(string.Join(" ", addRemoveCollection.CollectionAdds));
        Console.WriteLine(string.Join(" ", myList.CollectionAdds));
        Console.WriteLine(string.Join(" ", addRemoveCollection.CollectionRemovedItems));
        Console.WriteLine(string.Join(" ", myList.CollectionRemovedItems));
    }
Example #2
0
        private void AddItems(string[] wordsToAdd)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 3; i++)
            {
                if (i == 0)
                {
                    foreach (var word in wordsToAdd)
                    {
                        sb.Append(addCollection.AddItem(word) + " ");
                    }
                }
                else if (i == 1)
                {
                    foreach (var word in wordsToAdd)
                    {
                        sb.Append(addRemoveCollection.AddItem(word) + " ");
                    }
                }
                else
                {
                    foreach (var word in wordsToAdd)
                    {
                        sb.Append(myList.AddItem(word) + " ");
                    }
                }

                Console.WriteLine(sb.ToString().TrimEnd());
                sb.Clear();
            }
        }