public static void Main()
        {
            var collection = new ListyIterator <string>();

            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                var inputTokens = input
                                  .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                  .ToList();
                var command = inputTokens[0];
                inputTokens = inputTokens.Skip(1).ToList();

                try
                {
                    switch (command)
                    {
                    case "Create":
                        if (inputTokens.Any())
                        {
                            collection = new ListyIterator <string>(inputTokens);
                        }
                        break;

                    case "Print":
                        collection.Print();
                        break;

                    case "Move":
                        Console.WriteLine(collection.Move());
                        break;

                    case "HasNext":
                        Console.WriteLine(collection.HasNext());
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Example #2
0
        public static void Main()
        {
            ListyIterator listy = null;

            string inputInfo;

            while ((inputInfo = Console.ReadLine()) != "END")
            {
                var split = inputInfo.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    switch (split[0])
                    {
                    case "Create":

                        listy = new ListyIterator(split.Skip(1).ToArray());
                        break;

                    case "Move":
                        Console.WriteLine(listy.Move());

                        break;

                    case "HasNext":
                        Console.WriteLine(listy.HasNext());

                        break;

                    case "Print":
                        listy.Print();
                        break;

                    case "PrintAll":
                        listy.PrintAll();
                        break;
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Operation!");
                }
            }
        }
Example #3
0
        public static void Main()
        {
            var inputCreate     = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var inputCreateData = inputCreate.Skip(1).ToArray();

            var listyIterator = new ListyIterator <string>(inputCreateData);

            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                try
                {
                    switch (input)
                    {
                    case "Move":
                        Console.WriteLine(listyIterator.Move());
                        break;

                    case "Print":
                        listyIterator.Print();
                        break;

                    case "HasNext":
                        Console.WriteLine(listyIterator.HasNext());
                        break;

                    case "PrintAll":
                        foreach (var element in listyIterator)
                        {
                            Console.Write(element + " ");
                        }
                        Console.WriteLine();
                        break;
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "END")
                {
                    break;
                }

                if (input.Contains("Create"))
                {
                    List <string> items = input
                                          .Split()
                                          .Skip(1)
                                          .ToList();
                    listyIterator = new ListyIterator <string>(items);
                }
                else if (input == "Print")
                {
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (input == "HasNext")
                {
                    Console.WriteLine(listyIterator.HasNext());
                }
                else if (input == "Move")
                {
                    Console.WriteLine(listyIterator.Move());
                }
            }
        }
Example #5
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            ListyIterator <string> listyIterator = new ListyIterator <string>(
                input.Split(" ", StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList());

            input = Console.ReadLine();

            while (input != "END")
            {
                string[] tokens  = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string   command = tokens[0];

                try
                {
                    switch (command)
                    {
                    case "Move":
                        Console.WriteLine(listyIterator.Move());
                        break;

                    case "HasNext":
                        Console.WriteLine(listyIterator.HasNext());
                        break;

                    case "Print":
                        listyIterator.Print();
                        break;

                    default:
                        break;
                    }
                }
                catch (InvalidOperationException ioe)
                {
                    Console.WriteLine(ioe.Message);
                }

                input = Console.ReadLine();
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            string[] create = Console.ReadLine()
                              .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                              .Skip(1)
                              .ToArray();

            ListyIterator <string> iterator = new ListyIterator <string>(create);

            string cmd = Console.ReadLine();

            while (cmd != "END")
            {
                switch (cmd)
                {
                case "HasNext":
                    Console.WriteLine(iterator.HasNext());
                    break;

                case "Move":
                    Console.WriteLine(iterator.Move());
                    break;

                case "Print":
                    try
                    {
                        iterator.Print();
                    }
                    catch (InvalidOperationException)
                    {
                        Console.WriteLine("Invalid Operation!");
                    }
                    break;

                default:
                    break;
                }
                cmd = Console.ReadLine();
            }
        }
        public static void Main()
        {
            string[] createCommand            = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            ListyIterator <string> collection = null;

            if (createCommand.Length != 1)
            {
                List <string> parameters = createCommand.Skip(1).ToList();
                collection = new ListyIterator <string>(parameters);
            }

            while (true)
            {
                string input = Console.ReadLine();

                if (input == "END")
                {
                    break;
                }

                switch (input)
                {
                case "Print":
                    collection.Print();
                    break;

                case "HasNext":
                    Console.WriteLine(collection.HasNext());
                    break;

                case "Move":
                    Console.WriteLine(collection.Move());

                    break;

                default:
                    break;
                }
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            ListyIterator <string> collection = null;

            string command = Console.ReadLine();

            while (command != "END")
            {
                try
                {
                    var input    = command.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    var inputCmd = input[0];

                    if (inputCmd == "Create")
                    {
                        List <string> elements = input.Skip(1).ToList();
                        collection = new ListyIterator <string>(elements);
                    }
                    else if (inputCmd == "Move")
                    {
                        Console.WriteLine(collection.Move());
                    }
                    else if (inputCmd == "HasNext")
                    {
                        Console.WriteLine(collection.HasNext());
                    }
                    else if (inputCmd == "Print")
                    {
                        collection.Print();
                    }
                }
                catch (InvalidOperationException exception)
                {
                    Console.WriteLine(exception.Message);
                }


                command = Console.ReadLine();
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            string command;

            while ((command = Console.ReadLine()) != "END")
            {
                var tokens = command.Split();

                switch (tokens[0])
                {
                case "Create":
                    listyIterator = new ListyIterator <string>(tokens.Skip(1).ToArray());
                    break;

                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

                case "Print":
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (InvalidOperationException ioe)
                    {
                        Console.WriteLine(ioe.Message);
                    }
                    break;

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;

                default:
                    throw new ArgumentException();
                }
            }
        }
        public static void Main()
        {
            var create   = Console.ReadLine().Split();
            var elements = create.Skip(1).Take(create.Length - 1).ToList();

            var listyIterator = new ListyIterator <string>(elements);

            while (true)
            {
                var command = Console.ReadLine();

                if (command == "END")
                {
                    break;
                }

                switch (command)
                {
                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;

                case "Print":
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (InvalidOperationException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;
                }
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            string input;
            ListyIterator <string> listyIterator = null;

            while ((input = Console.ReadLine()) != "END")
            {
                var cmdArgs = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var command = cmdArgs[0];

                switch (command)
                {
                case "Create":
                    var elements = cmdArgs.Skip(1).ToArray();
                    listyIterator = new ListyIterator <string>(elements);
                    break;

                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

                case "Print":
                    try
                    {
                        Console.WriteLine(listyIterator.Print());
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }

                    break;

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;
                }
            }
        }
Example #12
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            string command = string.Empty;

            while ((command = Console.ReadLine()) != "END")
            {
                string[] elements = command
                                    .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                switch (elements[0])
                {
                case "Create":
                    listyIterator = new ListyIterator <string>(elements.Skip(1).ToArray());
                    break;

                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

                case "Print":
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (ArgumentException ae)
                    {
                        Console.WriteLine(ae.Message);
                    }
                    break;

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;
                }
            }
        }
Example #13
0
        static void Main(string[] args)
        {
            ListyIterator <string> iterator = new ListyIterator <string>();

            string command = Console.ReadLine();

            while (command != "END")
            {
                string[] splittedCommand = command.Split();

                if (splittedCommand[0] == "Create")
                {
                    iterator = new ListyIterator <string>(splittedCommand.Skip(1).ToArray());
                }
                else if (splittedCommand[0] == "Move")
                {
                    Console.WriteLine(iterator.Move());
                }
                else if (splittedCommand[0] == "Print")
                {
                    try
                    {
                        iterator.Print();
                    }
                    catch (InvalidOperationException ioe)
                    {
                        Console.WriteLine(ioe.Message);
                    }
                }
                else if (splittedCommand[0] == "HasNext")
                {
                    Console.WriteLine(iterator.HasNext());
                }


                command = Console.ReadLine();
            }
        }
Example #14
0
        static void Main(string[] args)
        {
            List <string> rawElements = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();

            rawElements.RemoveAt(0);

            if (rawElements.Count == 0)
            {
                rawElements = null;
            }

            ListyIterator <string> listyIterator = new ListyIterator <string>(rawElements);
            string input = Console.ReadLine();

            while (input != "END")
            {
                string[] command = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                switch (command[0])
                {
                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;

                case "Print":
                    Console.WriteLine(listyIterator.Print());
                    break;
                }

                input = Console.ReadLine();
            }
        }
Example #15
0
        public static void Main()
        {
            var createCommand = Console.ReadLine().Split().ToList();

            createCommand.RemoveAt(0);
            var iterator = new ListyIterator <string>(createCommand);

            var command = Console.ReadLine();

            while (command != "END")
            {
                switch (command)
                {
                case "Move":
                    Console.WriteLine(iterator.Move());
                    break;

                case "Print":
                    try
                    {
                        iterator.Print();
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;

                case "HasNext":
                    Console.WriteLine(iterator.HasNext());
                    break;
                }

                command = Console.ReadLine();
            }
        }
Example #16
0
 public Engine()
 {
     this.iterator = new ListyIterator();
 }
Example #17
0
        public static void Main()
        {
            List <string> createCommand = Console.ReadLine().Split().ToList();

            ListyIterator <string> listyIterator;

            if (createCommand.Count > 1)
            {
                var items = createCommand.Skip(1).ToList();
                listyIterator = new ListyIterator <string>(items);
            }
            else
            {
                listyIterator = new ListyIterator <string>();
            }

            string command = Console.ReadLine();

            while (command != "END")
            {
                switch (command)
                {
                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

                case "Print":
                    try
                    {
                        Console.WriteLine(listyIterator.Print());
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception.Message);
                    }

                    break;

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;

                case "PrintAll":
                    try
                    {
                        foreach (var item in listyIterator)
                        {
                            Console.Write($"{item} ");
                        }
                        Console.WriteLine();
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception.Message);
                        throw;
                    }
                    break;
                }

                command = Console.ReadLine();
            }
        }