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());
                }

                input = Console.ReadLine();
            }
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            ListyIterator <string> collections = new ListyIterator <string>();

            while (input != "END")
            {
                string[] token = input.Split();
                switch (token[0])
                {
                case "Create":
                {
                    if (token.Length > 0)
                    {
                        for (int i = 1; i < token.Length; i++)
                        {
                            collections.Collections.Add(token[i]);
                        }
                    }
                }
                break;

                case "Move":
                {
                    Console.WriteLine(collections.Move(collections.Collections));
                }
                break;

                case "Print":
                {
                    collections.Print(collections.Collections);
                }
                break;

                case "HasNext":
                {
                    Console.WriteLine(collections.HasNext(collections.Collections));
                }
                break;

                case "PrintAll":
                {
                    foreach (var item in collections.Collections)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine();
                }
                break;
                }

                input = Console.ReadLine();
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

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

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

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

                case "PrintAll":
                    string message = String.Empty;
                    foreach (string element in listyIterator)
                    {
                        message += element + " ";
                    }

                    Console.WriteLine(message.TrimEnd());
                    break;

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

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

                default:
                    break;
                }
            }
        }
Exemplo n.º 5
0
        public static void Main()
        {
            string[]      createCommand = Console.ReadLine().Split();
            List <string> collection    = createCommand.Skip(1).ToList();

            ListyIterator <string> test = new ListyIterator <string>(collection);

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

                if (command.Equals("END"))
                {
                    break;
                }

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

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

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

                    case "PrintAll":
                        StringBuilder sb = new StringBuilder();

                        foreach (var item in test)
                        {
                            sb.Append(item + " ");
                        }

                        Console.WriteLine(sb.ToString().TrimEnd());
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            var input = Console.ReadLine();
            ListyIterator <string> listy = new ListyIterator <string>();

            // listy.Listy = new List<string>();

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

                if (cmd == "Create")
                {
                    for (int i = 1; i < line.Length; i++)
                    {
                        listy.Listy.Add(line[i]);
                    }
                }
                if (cmd == "Move")
                {
                    Console.WriteLine(listy.Move());
                }
                if (cmd == "HasNext")
                {
                    Console.WriteLine(listy.HasNext());
                }
                if (cmd == "Print")
                {
                    try
                    {
                        Console.WriteLine(listy.Print());
                    }
                    catch (InvalidOperationException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                if (cmd == "PrintAll")
                {
                    Console.WriteLine(string.Join(' ', listy));
                }
                input = Console.ReadLine();
            }
        }
Exemplo n.º 7
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());
        }
        public static void Main(string[] args)
        {
            string[] inputArgs = Console.ReadLine().Split();

            string command = inputArgs[0];

            try
            {
                while (command != "END")
                {
                    switch (command)
                    {
                    case "Create":
                        customList = new ListyIterator <string>(inputArgs.Skip(1).ToArray());
                        break;

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

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

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

                    default:
                        break;
                    }

                    inputArgs = Console.ReadLine().Split();
                    command   = inputArgs[0];
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            string        command  = Console.ReadLine();
            List <string> elements = command.Split().Skip(1).ToList();

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

            while (command != "END")
            {
                if (command == "Print")
                {
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }

                else if (command == "Move")
                {
                    bool result = listyIterator.Move();
                    Console.WriteLine(result);
                }

                if (command == "HasNext")
                {
                    bool result = listyIterator.HasNext();
                    Console.WriteLine(result);
                }

                if (command == "PrintAll")
                {
                    Console.WriteLine(string.Join(" ", listyIterator));
                }

                command = Console.ReadLine();
            }
        }
        public static void Main()
        {
            string[]      createCommand = Console.ReadLine().Split();
            List <string> collection    = createCommand.Skip(1).ToList();

            ListyIterator <string> test = new ListyIterator <string>(collection);

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

                if (command.Equals("END"))
                {
                    break;
                }

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

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

                    case "Print":
                        test.Print();
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Exemplo n.º 11
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;
                }
            }
        }