Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _1__
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string command = string.Empty;
- while ((command = Console.ReadLine()) != "Registration")
- {
- string[] cmd = command.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
- switch (cmd[0])
- {
- case "Letters":
- if (cmd[1] == "Upper")
- {
- input = input.ToUpper();
- }
- else
- {
- input = input.ToLower();
- }
- Console.WriteLine(input);
- break;
- case "Reverse":
- int startInx = int.Parse(cmd[1]);
- int endInx = int.Parse(cmd[2]);
- if (startInx >= 0 && endInx < input.Length && startInx <= endInx)
- {
- Console.WriteLine(string.Join("", input.Substring(startInx, (endInx - startInx + 1)).Reverse()));
- }
- break;
- case "Substring":
- if (input.Contains(cmd[1]))
- {
- while (input.Contains(cmd[1]))
- {
- input = input.Remove(input.IndexOf(cmd[1]), cmd.Length);
- Console.WriteLine(input);
- }
- }
- //input = input.Replace(cmd[1], "");
- else
- {
- Console.WriteLine($"The username {input} doesn't contain {cmd[1]}.");
- }
- break;
- case "Replace":
- if (input.Contains(cmd[1]))
- {
- input = input.Replace(cmd[1], "-");
- Console.WriteLine(input);
- }
- break;
- case "IsValid":
- if (input.Contains(cmd[1]))
- {
- Console.WriteLine("Valid username.");
- }
- else
- {
- Console.WriteLine($"{cmd[1]} must be contained in your username.");
- }
- break;
- default:
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement