Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- string key = Console.ReadLine();
- string input;
- while ((input = Console.ReadLine()) != "Generate")
- {
- string[] cmd = input.Split(">>>");
- switch (cmd[0])
- {
- case "Contains": Contains(key, cmd[1]); break;
- case "Flip": key = Flip(key, cmd); break;
- case "Slice": key = Slice(key, cmd); break;
- }
- }
- Console.WriteLine($"Your activation key is: {key}");
- }
- private static void Contains(string key, string substring)
- {
- if (key.Contains(substring))
- Console.WriteLine($"{key} contains {substring}");
- else
- Console.WriteLine("Substring not found!");
- }
- private static string Flip(string key, string[] cmd)
- {
- int startIndex = int.Parse(cmd[2]);
- int endIndex = int.Parse(cmd[3]);
- string substring = key.Substring(startIndex, endIndex - startIndex);
- key = key.Remove(startIndex, endIndex - startIndex);
- if (cmd[1] == "Upper")
- substring = substring.ToUpper();
- else if (cmd[1] == "Lower")
- substring = substring.ToLower();
- key = key.Insert(startIndex, substring);
- Console.WriteLine(key);
- return key;
- }
- private static string Slice(string key, string[] cmd)
- {
- int startIndex = int.Parse(cmd[1]);
- int endIndex = int.Parse(cmd[2]);
- key = key.Remove(startIndex, endIndex - startIndex);
- Console.WriteLine(key);
- return key;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement