Esempio n. 1
0
        static void Main()
        {
            ListyIterator <string> setCollection = new ListyIterator <string>();

            while (true)
            {
                var input = Console.ReadLine()
                            .Split()
                            .ToList();

                string command = input[0];

                if (command == "END")
                {
                    break;
                }
                else if (command == "Create")
                {
                    input.RemoveAt(0);
                    setCollection.Create(input);
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(setCollection.HasNext());
                }
                else if (command == "Move")
                {
                    Console.WriteLine(setCollection.Move());
                }
                else if (command == "Print")
                {
                    Console.WriteLine(setCollection.Print());
                }
                else if (command == "PrintAll")
                {
                    Console.WriteLine(setCollection.PrintAll());
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            string command = Console.ReadLine();

            while (command != "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 "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;

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

                command = Console.ReadLine();
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            string command = Console.ReadLine();

            string[] arr = command.Split();
            ListyIterator <string> list = new ListyIterator <string>(arr.Skip(1).ToArray());

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

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

                case "PrintAll":
                    Console.WriteLine(string.Join(" ", list));
                    break;

                case "Print":
                    try
                    {
                        Console.WriteLine(list.Print());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;
                }
                command = Console.ReadLine();
            }
        }
Esempio n. 4
0
        public void Run()
        {
            IListyIterator <string> myList;

            string[] inputArgs = Console.ReadLine().Split().Skip(1).ToArray();
            try
            {
                myList = new ListyIterator <string>(inputArgs);
                string command;
                while ((command = Console.ReadLine()) != "END")
                {
                    try
                    {
                        switch (command.ToUpper())
                        {
                        case "HASNEXT": Console.WriteLine(myList.HasNext()); break;

                        case "PRINT": Console.WriteLine(myList.Print());; break;

                        case "MOVE": Console.WriteLine(myList.Move()); break;

                        case "PRINTALL": Console.WriteLine(string.Join(" ", myList)); break;
                        }
                    }
                    catch (InvalidOperationException ioe)
                    {
                        Console.WriteLine(ioe.Message);
                    }
                }
            }
            catch (InvalidOperationException ioe)
            {
                Console.WriteLine(ioe.Message);
                Environment.Exit(0);
            }
        }