petarkobakov

Warrior's Quest

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