Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Help1.Hogwarts
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string spell = Console.ReadLine();
- string input = Console.ReadLine();
- while (input != "Abracadabra")
- {
- string[] command = input.Split(' ',StringSplitOptions.RemoveEmptyEntries);
- switch (command[0])
- {
- case "Abjuration":
- spell = spell.ToUpper();
- Console.WriteLine(spell);
- break;
- case "Necromancy":
- spell = spell.ToLower();
- Console.WriteLine(spell);
- break;
- case "Illusion":
- int index =int.Parse(command[1]);
- string newLetter = command[2];
- if (index >= 0 && index <= spell.Length)
- {
- spell = spell.Remove(index,index);
- spell = spell.Insert(index, newLetter);
- Console.WriteLine("Done");
- }
- else
- {
- Console.WriteLine("The spell was too weak.");
- }
- break;
- case "Divination":
- string firstSub = command[1];
- string secondSub = command[2];
- if (spell.Contains(firstSub))
- {
- spell = spell.Replace(firstSub, secondSub);
- Console.WriteLine(spell);
- }
- break;
- case "Alteration":
- string substring = command[1];
- if (spell.Contains(substring))
- {
- spell = spell.Replace(substring, "");
- Console.WriteLine(spell);
- }
- break;
- default:
- Console.WriteLine("The spell did not work!");
- break;
- }
- input = Console.ReadLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement