petyaminkova91

Untitled

Oct 27th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace _03_QuestJournal
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<string> quests = Console.ReadLine().Split(", ").ToList();
  12.  
  13. string input = Console.ReadLine();
  14.  
  15. while (input != "Retire!")
  16. {
  17. List<string> commandParts = input.Split(" - ").ToList();
  18.  
  19. string command = commandParts[0];
  20.  
  21. if (command == "Start")
  22. {
  23. string questToAdd = commandParts[1];
  24.  
  25. if (!quests.Contains(questToAdd))
  26. {
  27. quests.Add(questToAdd);
  28. }
  29. }
  30. else if (command == "Complete")
  31. {
  32. string questToRemove = commandParts[1];
  33. // ako nqmash element za premahvane kakvo stava
  34. if (quests.Contains(questToRemove))
  35. {
  36. quests.Remove(questToRemove);
  37. }
  38. }
  39. else if (command == "Side Quest")
  40. {
  41. List<string> parts = commandParts[1].Split(":").ToList();
  42. string quest = parts[0];
  43. string sideQuest = parts[1];
  44.  
  45. if (quests.Contains(quest) && !quests.Contains(sideQuest))
  46. {
  47. int indexOfQuestToAddAt = quests.IndexOf(quest) + 1;
  48. quests.Insert(indexOfQuestToAddAt, sideQuest);
  49. }
  50. }
  51. else if (command == "Renew")
  52. {
  53. string questToChangeLast = commandParts[1];
  54. if (quests.Contains(questToChangeLast))
  55. {
  56. quests.Remove(questToChangeLast);
  57. quests.Add(questToChangeLast);
  58. }
  59. }
  60.  
  61. input = Console.ReadLine();
  62. }
  63.  
  64. Console.WriteLine(String.Join(", ", quests));
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment