Example #1
0
        static void Main(string[] args)
        {
            string[] createCommandItems = Console.ReadLine()
                                          .Split()
                                          .Skip(1)
                                          .ToArray();

            ListyIterator <string> list = new ListyIterator <string>(createCommandItems);

            string command = Console.ReadLine();

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

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

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

                case "PrintAll":
                    list.PrintAll();
                    break;
                }

                command = Console.ReadLine();
            }
        }
Example #2
0
        public static void Main()
        {
            List <string>          createCommand = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            ListyIterator <string> list          = new ListyIterator <string>(createCommand.GetRange(1, createCommand.Count - 1));

            string input = Console.ReadLine();

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

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

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

                case "PrintAll":
                    list.PrintAll();
                    break;

                default:
                    break;
                }
                input = Console.ReadLine();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            ListyIterator <string> collection = new ListyIterator <string>();

            while (input != "END")
            {
                string[] tokens  = input.Split();
                string   command = tokens[0].ToLower();
                switch (command)
                {
                case "create":
                    List <string> nameCollection = new List <string>();
                    for (int i = 1; i < tokens.Length; i++)
                    {
                        nameCollection.Add(tokens[i]);
                    }
                    collection.Create(nameCollection);
                    break;

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

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

                case "print":
                    try
                    {
                        collection.Print();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;

                case "printall":
                    try
                    {
                        collection.PrintAll();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;

                default:
                    break;
                }

                input = Console.ReadLine();
            }
        }
Example #4
0
        public static void Main()
        {
            var createCmd = Console.ReadLine().Split().ToList();
            var elements  = createCmd.Skip(1).ToList();
            ListyIterator <string> listIterator = new ListyIterator <string>(elements);

            var cmd = Console.ReadLine();

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

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

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

                case "PrintAll":
                    try
                    {
                        Console.WriteLine(listIterator.PrintAll());
                    }
                    catch (InvalidOperationException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;
                }

                cmd = Console.ReadLine();
            }
        }
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;

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

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

                input = Console.ReadLine();
            }
        }
Example #6
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;

                case "PrintAll":
                    Console.WriteLine(listyIterator.PrintAll());
                    break;
                }
            }
        }
Example #7
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")
            {
                try
                {
                    switch (command)
                    {
                    case "Move":
                        Console.WriteLine(iterator.Move());
                        break;

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

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

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

                command = Console.ReadLine();
            }
        }
Example #8
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;

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

                input = Console.ReadLine();
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            var input      = Console.ReadLine();
            var listItems  = input.Split().Skip(1).ToArray();
            var collection = new ListyIterator <string>(listItems);

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

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

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

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

                    default:
                        break;
                    }
                }
                catch (InvalidOperationException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Example #10
0
        static void Main( )
        {
            ListyIterator <string> listyIterator = new ListyIterator <string>();

            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                var args = input.Split();
                var cmd  = args[0];

                switch (cmd)
                {
                case "Create":
                    listyIterator.Create(args.Skip(1).ToArray());
                    break;

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

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

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

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

                default:
                    break;
                }
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            var tokens = Console.ReadLine().Split();
            ListyIterator <string> iterator = new ListyIterator <string>(tokens.Skip(1).ToArray());

            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                switch (input)
                {
                case "Move":
                    bool isMoved = iterator.Move();
                    iterator.Print(isMoved);
                    break;

                case "PrintAll":
                    iterator.PrintAll(); break;

                case "HasNext":
                    bool next = iterator.HasNext();
                    iterator.Print(next);
                    break;

                case "Print":
                    try
                    {
                        iterator.Print();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;
                }
            }
        }
        static void Main()
        {
            var input = Console.ReadLine();
            ListyIterator <string> iterator = null;

            while (input != "END")
            {
                var tokens = input.Split(' ').ToList();
                switch (tokens[0])
                {
                case "Create":
                    iterator = new ListyIterator <string>(new List <string>(tokens.Skip(1)));
                    break;

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

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

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

                case "PrintAll":
                    iterator.PrintAll();
                    break;

                default: break;
                }

                input = Console.ReadLine();
            }
        }