Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Clones
  5. {
  6. public class Clon
  7. {
  8. public List<string> izucheniecomand = new List<string>();
  9. public List<string> otcati = new List<string>();
  10. public bool cloneli = false;
  11. }
  12. public class CloneVersionSystem : ICloneVersionSystem
  13. {
  14. public Dictionary<string, Clon> dictionary = new Dictionary<string, Clon>() { { "1", new Clon() } };
  15.  
  16. public string Execute(string query)
  17. {
  18. var array = query.Split(' ');
  19. if (!(dictionary.ContainsKey(array[1])))
  20. return null;
  21. switch (array[0])
  22. {
  23. case "learn":
  24. if (dictionary[array[1]].izucheniecomand.Contains(array[2])) break;
  25. dictionary[array[1]].izucheniecomand.Add(array[2]);
  26. break;
  27.  
  28. case "rollback":
  29. if (dictionary[array[1]].izucheniecomand.Count == 0) break;
  30. dictionary[array[1]].otcati.Add((dictionary[array[1]].izucheniecomand[dictionary[array[1]].izucheniecomand.Count - 1]));
  31. dictionary[array[1]].izucheniecomand.RemoveAt(dictionary[array[1]].izucheniecomand.Count - 1);
  32. break;
  33.  
  34. case "clone":
  35. if (dictionary[array[1]].cloneli == true) break;
  36. dictionary.Add((int.Parse(array[1]) + 1).ToString(), new Clon());
  37. dictionary[(int.Parse(array[1]) + 1).ToString()].izucheniecomand = new List<string>(dictionary[array[1]].izucheniecomand);
  38. dictionary[(int.Parse(array[1]) + 1).ToString()].otcati = new List<string>(dictionary[array[1]].otcati);
  39. dictionary[array[1]].cloneli = true;
  40. break;
  41.  
  42. case "check":
  43. if (dictionary[array[1]].izucheniecomand.Count == 0) return "basic";
  44. else return dictionary[array[1]].izucheniecomand[dictionary[array[1]].izucheniecomand.Count - 1];
  45. }
  46.  
  47. return null;
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement