Advertisement
raziel13

Tsem_account

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