Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            var comamndExecutor = new CommandExecutor();
            var linkedList      = new CustomLinkedList <int>();
            var countCommands   = int.Parse(Console.ReadLine());

            for (var i = 0; i < countCommands; i++)
            {
                var input = Console.ReadLine().Split();
                comamndExecutor.Execute(linkedList, input);
            }

            linkedList.Print();
        }
Exemplo n.º 2
0
        public void Execute(CustomLinkedList <int> linkedList, string[] input)
        {
            var commandName = input[0];
            var element     = int.Parse(input[1]);

            if (commandName == "Add")
            {
                linkedList.Add(element);
                return;
            }
            if (commandName == "Remove")
            {
                linkedList.Remove(element);
                return;
            }

            throw new ArgumentException("Invalid command name!");
        }