Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Tseam_Account
  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.                     if (Games.Contains(game))
  50.                     {
  51.                         string[] tok = game.Split('-');
  52.                         string gameName = tok[0];
  53.                         string expansion = tok[1];
  54.  
  55.                         if (Games.Contains(gameName))
  56.                         {
  57.                             int index = Games.IndexOf(gameName);
  58.                             string value = $"{gameName}:{expansion}";
  59.  
  60.                             if (index == Games.Count - 1)
  61.                             {
  62.                                 Games.Add(value);
  63.                             }
  64.                             else
  65.                             {
  66.                                 Games.Insert(index + 1, value);
  67.                             }
  68.  
  69.                         }
  70.                     }
  71.  
  72.                 }
  73.  
  74.                 line = Console.ReadLine();
  75.             }
  76.  
  77.             Console.WriteLine(string.Join(" ", Games));
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement