Advertisement
Guest User

Warriors Quest

a guest
Aug 6th, 2020
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.84 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace _01._Warrior_s_Quest
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string skill = Console.ReadLine();
  11.  
  12.             string input = Console.ReadLine();
  13.             while (input != "For Azeroth")
  14.             {
  15.                 string[] tokens = input.Split(" ");
  16.                 string command = tokens[0];
  17.  
  18.                 if (command == "GladiatorStance")
  19.                 {
  20.                     skill = skill.ToUpper();
  21.                     Console.WriteLine(skill);
  22.                 }
  23.                 else if (command == "DefensiveStance")
  24.                 {
  25.                     skill = skill.ToLower();
  26.                     Console.WriteLine(skill);
  27.                 }
  28.                 else if (command == "Dispel")
  29.                 {
  30.                     var indexToReplace = int.Parse(tokens[1]);
  31.                     char charToReplace = char.Parse(tokens[2]);
  32.  
  33.                     if (indexToReplace < skill.Length && indexToReplace >= 0)
  34.                     {
  35.                         char[] temp = skill.ToCharArray();
  36.                         temp[indexToReplace] = charToReplace;
  37.  
  38.                         skill = new string(temp);
  39.                         Console.WriteLine("Success!");
  40.                     }
  41.                     else
  42.                     {
  43.                         Console.WriteLine("Dispel too weak.");
  44.                     }
  45.                 }
  46.                 else if (command == "Target")
  47.                 {
  48.                     var action = tokens[1];
  49.                     if (action == "Change")
  50.                     {
  51.                         var substring = tokens[2];
  52.                         var newString = tokens[3];
  53.                         if (skill.Contains(substring))
  54.                         {
  55.                             skill = skill.Replace(substring, newString);
  56.                             Console.WriteLine(skill);
  57.                         }
  58.                     }
  59.                     else if (action == "Remove")
  60.                     {
  61.                         var substring = tokens[2];
  62.                         if (skill.Contains(substring))
  63.                         {
  64.                             var index = skill.IndexOf(substring);
  65.  
  66.                             skill = skill.Remove(index, substring.Length);
  67.                             Console.WriteLine(skill);
  68.                         }
  69.                         else
  70.                         {
  71.                             Console.WriteLine("Command doesn't exist!");
  72.                         }
  73.                     }
  74.                 }
  75.                
  76.                 else
  77.                 {
  78.                     Console.WriteLine("Command doesn't exist!");
  79.                 }
  80.  
  81.                 input = Console.ReadLine();
  82.             }
  83.            
  84.         }
  85.         }
  86.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement