Advertisement
KeepCoding

03. Tseam Account

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