veno0

Untitled

Mar 27th, 2020
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Http.Headers;
  5. using System.Security.Claims;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace softuni_Regex
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string command;
  15.             string input = Console.ReadLine();
  16.            
  17.            
  18.             while ((command = Console.ReadLine()) != "For Azeroth")
  19.             {
  20.                 if (command == "GladiatorStance")
  21.                 {
  22.                     input = input.ToUpper();
  23.                     Console.WriteLine(input);
  24.                 }
  25.                 else if (command == "DefensiveStance")
  26.                 {
  27.                     input = input.ToLower();
  28.                     Console.WriteLine(input);
  29.                 }
  30.                 else if (command.Contains("Dispel"))
  31.                 {
  32.                     string[] splitted = command.Split();
  33.                     int index = int.Parse(splitted[1]);
  34.                     char letter = Char.Parse(splitted[2]);
  35.                     if (index >= 0 && index < input.Length)
  36.                     {
  37.                         input = input.Replace(input[index], letter);
  38.                         Console.WriteLine("Success!");
  39.                     }
  40.                     else
  41.                     {
  42.                         Console.WriteLine("Dispel too weak.");
  43.                     }
  44.  
  45.                 }
  46.                 else if (command.Contains("Target Change"))
  47.                 {
  48.                     string[] splitted = command.Split();
  49.                     string firstSubstring = splitted[2];
  50.                     string secondSubsstring = splitted[3];
  51.                     input = input.Replace(firstSubstring, secondSubsstring);
  52.                     Console.WriteLine(input);
  53.                 }
  54.                 else if (command.Contains("Remove"))
  55.                 {
  56.                     string[] splitted = command.Split();
  57.                     string remove = splitted[2];
  58.                     input = input.Replace(remove, "");
  59.                     Console.WriteLine(input);
  60.                 }
  61.                 else
  62.                 {
  63.                     Console.WriteLine("Command doesn't exist!");
  64.                 }
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment