Ejemplo n.º 1
0
 public static void Main()
 {
     CustomList <int> start = new CustomList <int>();
 }
Ejemplo n.º 2
0

        
Ejemplo n.º 3
0
        public static void Main()
        {
            CustomList <string> customList = new CustomList <string>();

            string element = "";

            string[] args = Console.ReadLine().Split();

            while (args[0] != "END")
            {
                string command = args[0];
                switch (command)
                {
                case "Add":
                    element = args[1];
                    customList.Add(element);
                    break;

                case "Remove":
                    int index = int.Parse(args[1]);
                    customList.Remove(index);
                    break;

                case "Contains":
                    element = args[1];
                    Console.WriteLine(customList.Contains(element));
                    break;

                case "Swap":
                    int index1 = int.Parse(args[1]);
                    int index2 = int.Parse(args[2]);
                    customList.Swap(index1, index2);
                    break;

                case "Greater":
                    element = args[1];
                    Console.WriteLine(customList.CountGreaterThan(element));
                    break;

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

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

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

                case "Print":
                    foreach (var item in customList)
                    {
                        Console.WriteLine(item);
                    }
                    break;
                }

                args = Console.ReadLine().Split();
            }
        }
 public CommandInterpreter()
 {
     this.customList = new CustomList <string>();
 }
Ejemplo n.º 5
0

        
Ejemplo n.º 6
0
        public static void Main()
        {
            var    customList = new CustomList <string>();
            string commandLine;

            while ((commandLine = Console.ReadLine()) != "END")
            {
                var cmdParams = commandLine.Split();
                var command   = cmdParams[0];

                switch (command)
                {
                case "Add":
                    var element = cmdParams[1];
                    customList.Add(element);
                    break;

                case "Remove":
                    var index = int.Parse(cmdParams[1]);
                    customList.Remove(index);
                    break;

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

                case "Contains":
                    var givenElement = cmdParams[1];
                    var result       = customList.Contains(givenElement);
                    Console.WriteLine(result);
                    break;

                case "Swap":
                    var firstIndex  = int.Parse(cmdParams[1]);
                    var secondIndex = int.Parse(cmdParams[2]);
                    customList.Swap(firstIndex, secondIndex);
                    break;

                case "Greater":
                    var count = customList.CountGreaterThan(cmdParams[1]);
                    Console.WriteLine(count);
                    break;

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

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

                case "Print":
                    foreach (var item in customList)
                    {
                        Console.WriteLine(item);
                    }
                    break;

                default:
                    Console.WriteLine("Invalid command!");
                    break;
                }
            }
        }
Ejemplo n.º 8
0
        public CustomList <T> Zip(CustomList <T> ListTwo)
        {
            CustomList <T> thirdList = new CustomList <T>();

            return(thirdList);
        }