Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Globalization;
- string spellOgi = Console.ReadLine();
- string commandOgi;
- while ((commandOgi = Console.ReadLine()) != "Abracadabra")
- {
- string[] commArg = commandOgi.Split(' ', StringSplitOptions.RemoveEmptyEntries);
- string curCommand = commArg[0];
- if (curCommand == "Abjuration")
- {
- spellOgi = spellOgi.ToUpper();
- Console.WriteLine(spellOgi);
- }
- else if (curCommand == "Necromancy")
- {
- spellOgi = spellOgi.ToLower();
- Console.WriteLine(spellOgi);
- }
- else if (curCommand == "Illusion")
- {
- int index = int.Parse(commArg[1]);
- if (index >= 0 && index < spellOgi.Length)
- {
- spellOgi = spellOgi.Remove(index, 1);
- string newChar = commArg[2];
- spellOgi = spellOgi.Insert(index, newChar);
- Console.WriteLine("Done!");
- }
- else
- {
- Console.WriteLine("The spell was too weak.");
- }
- }
- else if (curCommand == "Divination")
- {
- string firstString = commArg[1];
- string secondString = commArg[2];
- if (spellOgi.Contains(firstString))
- {
- spellOgi = spellOgi.Replace(firstString, secondString);
- Console.WriteLine(spellOgi);
- }
- }
- else if (curCommand == "Alteration")
- {
- string substring = commArg[1];
- if (spellOgi.Contains(substring))
- {
- int indexOfSub = spellOgi.IndexOf(substring);
- spellOgi = spellOgi.Remove(indexOfSub, substring.Length);
- Console.WriteLine(spellOgi);
- }
- }
- else
- {
- Console.WriteLine("The spell did not work!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement