Advertisement
silvana1303

username

Aug 7th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace _02._Boss_Rush
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string input = Console.ReadLine();
  13.  
  14.             string[] command = Console.ReadLine().Split();
  15.  
  16.             while (command[0] != "Sign")
  17.             {
  18.                 if (command[0] == "Case")
  19.                 {
  20.                     if (command[1] == "lower")
  21.                     {
  22.                         input = input.ToLower();
  23.                     }
  24.                     else
  25.                     {
  26.                         input = input.ToUpper();
  27.                     }
  28.  
  29.                     Console.WriteLine(input);
  30.                 }
  31.                 if (command[0] == "Reverse")
  32.                 {
  33.                     int start = int.Parse(command[1]);
  34.                     int end = int.Parse(command[2]);
  35.  
  36.                     if ((start >= 0 && start < input.Length) && end >= 0 && end < input.Length)
  37.                     {
  38.                         string substring = input.Substring(start, end - start + 1);
  39.                         char[] reverse = substring.Reverse().ToArray();
  40.                         string output = new string(reverse);
  41.                         Console.WriteLine(output);
  42.                     }  
  43.                 }
  44.                 if (command[0] == "Cut")
  45.                 {
  46.                     if (input.Contains(command[1]))
  47.                     {
  48.                         int index = input.IndexOf(command[1]);
  49.                         input = input.Remove(index, command[1].Length);
  50.                         Console.WriteLine(input);
  51.                     }
  52.                     else
  53.                     {
  54.                         Console.WriteLine($"The word {input} doesn't contain {command[1]}.");
  55.                     }
  56.                 }
  57.                 if (command[0] == "Replace")
  58.                 {
  59.                     input = input.Replace(command[1], "*");
  60.                     Console.WriteLine(input);
  61.                 }
  62.                 if (command[0] == "Check")
  63.                 {
  64.                     if (input.Contains(command[1]))
  65.                     {
  66.                         Console.WriteLine("Valid");
  67.                     }
  68.                     else
  69.                     {
  70.                         Console.WriteLine($"Your username must contain {command[1]}.");
  71.                     }
  72.                 }
  73.  
  74.                 command = Console.ReadLine().Split();
  75.             }
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement