Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _02MemoryView
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> games = Console.ReadLine().Split().ToList();
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "Play!")
- {
- break;
- }
- string[] tokens = command.Split();
- string action = tokens[0];
- if (action == "Install")
- {
- string game = tokens[1];
- if (!games.Contains(game))
- {
- games.Add(game);
- }
- }
- else if (action == "Uninstall")
- {
- string game = tokens[1];
- if (games.Contains(game))
- {
- games.Remove(game);
- }
- }
- else if (action == "Update")
- {
- string game = tokens[1];
- if (games.Contains(game))
- {
- int index = games.IndexOf(game);
- games.Add(game);
- games.RemoveAt(index);
- }
- }
- else if (action == "Expansion")
- {
- string[] info = tokens[1].Split('-');
- string game = info[0];
- string expansion = info[1];
- if (games.Contains(game))
- {
- int index = games.IndexOf(game);
- games.Insert(index + 1, game + ":" + expansion);
- }
- }
- }
- Console.WriteLine(string.Join(" ",games));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement