Advertisement
bullit3189

Tseam Account - TFExam - 25Apr18

Feb 2nd, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace _02MemoryView
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<string> games = Console.ReadLine().Split().ToList();
  12.  
  13. while (true)
  14. {
  15. string command = Console.ReadLine();
  16.  
  17. if (command == "Play!")
  18. {
  19. break;
  20. }
  21.  
  22. string[] tokens = command.Split();
  23.  
  24. string action = tokens[0];
  25.  
  26. if (action == "Install")
  27. {
  28. string game = tokens[1];
  29.  
  30. if (!games.Contains(game))
  31. {
  32. games.Add(game);
  33. }
  34. }
  35. else if (action == "Uninstall")
  36. {
  37. string game = tokens[1];
  38.  
  39. if (games.Contains(game))
  40. {
  41. games.Remove(game);
  42. }
  43. }
  44. else if (action == "Update")
  45. {
  46. string game = tokens[1];
  47.  
  48. if (games.Contains(game))
  49. {
  50. int index = games.IndexOf(game);
  51. games.Add(game);
  52. games.RemoveAt(index);
  53. }
  54. }
  55. else if (action == "Expansion")
  56. {
  57.  
  58. string[] info = tokens[1].Split('-');
  59. string game = info[0];
  60. string expansion = info[1];
  61.  
  62. if (games.Contains(game))
  63. {
  64. int index = games.IndexOf(game);
  65. games.Insert(index + 1, game + ":" + expansion);
  66. }
  67.  
  68. }
  69. }
  70.  
  71. Console.WriteLine(string.Join(" ",games));
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement