Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            ISoftUniList <string> softUniList = new SoftUniList <string>();

            string input = Console.ReadLine();

            while (input != "END")
            {
                string[] inputArgs = input.Split();

                string command = inputArgs[0];

                string element = "";

                switch (command)
                {
                case "Add":
                    element = inputArgs[1];
                    softUniList.Add(element);
                    break;

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

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

                case "Swap":
                    int firstIndex  = int.Parse(inputArgs[1]);
                    int secondIndex = int.Parse(inputArgs[2]);
                    softUniList.Swap(firstIndex, secondIndex);
                    break;

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

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

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

                case "Print":
                    Console.WriteLine(softUniList);
                    break;
                }

                input = Console.ReadLine();
            }
        }
Exemplo n.º 2
0
        public static void Main()
        {
            ISoftUniList <string> softUniList = new SoftUniList <string>();

            string input = Console.ReadLine();

            while (input != "END")
            {
                string[] inputArgs = input.Split();
                string   command   = inputArgs[0];

                switch (command)
                {
                case "Add":
                    softUniList.Add(inputArgs[1]);
                    break;

                case "Remove":
                    softUniList.Remove(int.Parse(inputArgs[1]));
                    break;

                case "Contains":
                    Console.WriteLine(softUniList.Contains(inputArgs[1]));
                    break;

                case "Swap":
                    softUniList.Swap(int.Parse(inputArgs[1]), int.Parse(inputArgs[2]));
                    break;

                case "Greater":
                    Console.WriteLine(softUniList.CountGreaterThan(inputArgs[1]));
                    break;

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

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

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

                default:
                    throw new ArgumentException();
                }

                input = Console.ReadLine();
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            SoftUniList <string> softUniList = new SoftUniList <string>();

            softUniList.Add("Gosho");
            softUniList.Add("Pesho");
            softUniList.Add("Ivan");
            softUniList.Remove("Iv12314214an");

            foreach (var item in softUniList)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("-----");

            softUniList[0] = "Pavel";

            for (int i = 0; i < softUniList.Count; i++)
            {
                Console.WriteLine(softUniList[i]);
            }
        }