Advertisement
Iskrenov84

Untitled

Apr 3rd, 2022
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.43 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4.  
  5. namespace Help1.Hogwarts
  6. {
  7.     internal class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string spell = Console.ReadLine();
  12.  
  13.  
  14.             string input  = Console.ReadLine();
  15.  
  16.             while (input != "Abracadabra")
  17.             {
  18.                 string[] command = input.Split(' ',StringSplitOptions.RemoveEmptyEntries);
  19.  
  20.                 switch (command[0])
  21.                 {
  22.                     case "Abjuration":
  23.                         spell = spell.ToUpper();
  24.                         Console.WriteLine(spell);
  25.                         break;
  26.                     case "Necromancy":
  27.                         spell = spell.ToLower();
  28.                         Console.WriteLine(spell);
  29.                         break;
  30.                     case "Illusion":
  31.                         int index =int.Parse(command[1]);
  32.                         string newLetter = command[2];
  33.                         if (index >= 0 && index <= spell.Length)
  34.                         {
  35.                             spell = spell.Remove(index,index);
  36.                             spell = spell.Insert(index, newLetter);
  37.                             Console.WriteLine("Done");
  38.                         }
  39.                         else
  40.                         {
  41.                             Console.WriteLine("The spell was too weak.");
  42.                         }
  43.                         break;
  44.                     case "Divination":
  45.                         string firstSub = command[1];
  46.                         string secondSub = command[2];
  47.                         if (spell.Contains(firstSub))
  48.                         {
  49.                             spell = spell.Replace(firstSub, secondSub);
  50.                             Console.WriteLine(spell);
  51.                         }
  52.                         break;
  53.                     case "Alteration":
  54.                         string substring = command[1];
  55.                         if (spell.Contains(substring))
  56.                         {
  57.                             spell = spell.Replace(substring, "");
  58.                             Console.WriteLine(spell);
  59.                         }
  60.                         break;
  61.                         default:
  62.                         Console.WriteLine("The spell did not work!");
  63.                         break;
  64.                 }
  65.                     input = Console.ReadLine();
  66.             }
  67.         }
  68.     }
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement