Advertisement
parunowaa

01.Activation_Keys

Dec 10th, 2021
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _01.Activation_Keys
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.             string command = Console.ReadLine();
  12.             string result = input;
  13.             while (command != "Generate")
  14.             {
  15.                 string[] cmd = command.Split(">>>").ToArray();
  16.                 var cmd1 = cmd[0];
  17.                 var cmd2 = cmd[1];
  18.  
  19.                 if (cmd1 == "Contains" && result.Contains(cmd2))
  20.                 {
  21.                     Console.WriteLine($"{result} contains {cmd2}");
  22.                 }
  23.                 else if (cmd1 == "Contains" && !(result.Contains(cmd2)))
  24.                 {
  25.                     Console.WriteLine("Substring not found!");
  26.                 }
  27.  
  28.                 if (cmd1 == "Flip" && cmd2 == "Upper")
  29.                 {
  30.                     int cmd3 = int.Parse(cmd[2]);
  31.                     int cmd4 = int.Parse(cmd[3]);
  32.                     string editedString = result.Substring(0, cmd3) + result.Substring(cmd3, cmd4 - cmd3).ToUpper() + result.Substring(cmd4);
  33.                     Console.WriteLine(editedString);
  34.                     result = editedString;
  35.                 }
  36.                 else if (cmd1 == "Flip" && cmd2 == "Lower")
  37.                 {
  38.                     int cmd3 = int.Parse(cmd[2]);
  39.                     int cmd4 = int.Parse(cmd[3]);
  40.                     string editedString = result.Substring(0, cmd3) + result.Substring(cmd3, cmd4 - cmd3).ToLower() + result.Substring(cmd4);
  41.                     Console.WriteLine(editedString);
  42.                     result = editedString;
  43.                 }
  44.  
  45.                 if (cmd1 == "Slice")
  46.                 {
  47.                     int cmd3 = int.Parse(cmd[2]);
  48.                     string editedString = result.Remove(int.Parse(cmd2), cmd3 - int.Parse(cmd2));
  49.                     Console.WriteLine(editedString);
  50.                     result = editedString;
  51.                 }
  52.  
  53.                 command = Console.ReadLine();
  54.             }
  55.  
  56.             Console.WriteLine($"Your activation key is: {result}");
  57.         }
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement