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; case "Sort": softUniList.Sorter(); break; default: throw new ArgumentException(); } input = Console.ReadLine(); } }
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 "Sort": softUniList.Sort(); break; case "Print": Console.WriteLine(softUniList); break; } input = Console.ReadLine(); } }