Example #1
0
        private static void UseCommands(string input)
        {
            string[] splitInput = input.Split();

            switch (splitInput[0].ToLower())
            {
            case "create":
                for (int i = 1; i < splitInput.Length; i++)
                {
                    content.Add(splitInput[i]);
                }
                listyIterator = new ListyIterator(content);
                break;

            case "move":
                Console.WriteLine(listyIterator.MoveNext());
                break;

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

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

            case "printall":
                listyIterator.PrintAll();
                break;
            }
        }
Example #2
0
        static void Main()
        {
            string[] args            = Console.ReadLine().Split().Skip(1).ToArray();
            var      myListyIterator = new ListyIterator <string>(args);

            StringBuilder sb = new StringBuilder();
            string        input;

            while ((input = Console.ReadLine()) != "END")
            {
                try
                {
                    switch (input)
                    {
                    case "HasNext":
                        sb.AppendLine(myListyIterator.HasNext().ToString());
                        break;

                    case "Print":
                        sb.AppendLine(myListyIterator.Print());
                        break;

                    case "Move":
                        sb.AppendLine(myListyIterator.Move().ToString());
                        break;

                    case "PrintAll":
                        sb.AppendLine(myListyIterator.PrintAll());
                        break;

                    default:
                        break;
                    }
                }
                catch (ArgumentOutOfRangeException)
                {
                    sb.AppendLine("Invalid Operation!");
                }
            }

            Console.WriteLine(sb.ToString().TrimEnd());
        }
Example #3
0
        public static void Main()
        {
            var createCommand = Console.ReadLine()
                                .Split(new string[] { "Create", " " }, StringSplitOptions.RemoveEmptyEntries)
                                .ToArray();

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

            string input = Console.ReadLine();

            while (input != "END")
            {
                var tokens = input
                             .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                             .ToArray();

                string command = tokens[0];

                if (command == "Move")
                {
                    Console.WriteLine(listyIterator.Move());
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(listyIterator.HasNext());
                }
                else if (command == "Print")
                {
                    Console.WriteLine(listyIterator.Print());
                }
                else if (command == "PrintAll")
                {
                    Console.WriteLine(listyIterator.PrintAll());
                }

                input = Console.ReadLine();
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            ListyIterator <string> listy = null;

            while (true)
            {
                var splitedInput = Console.ReadLine().Split(" ");

                if (splitedInput[0] == "END")
                {
                    break;
                }

                switch (splitedInput[0])
                {
                case "Create":
                    listy = new ListyIterator <string>(splitedInput.Skip(1).ToList());
                    break;

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

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

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

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