Advertisement
KeepCoding

P03 SteamAccount

Jun 24th, 2018
994
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 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.             string line = Console.ReadLine();
  14.  
  15.             while (line != "Play!")
  16.             {
  17.                 string[] tokens = line.Split();
  18.                 string comand = tokens[0];
  19.                 string game = tokens[1];
  20.  
  21.                 if (comand == "Install")
  22.                 {
  23.                     if (Games.Contains(game) == false)
  24.                     {
  25.                         Games.Add(game);
  26.                     }
  27.                 }
  28.                 else if (comand == "Uninstall")
  29.                 {
  30.                     if (Games.Contains(game) == true)
  31.                     {
  32.                         Games.Remove(game);
  33.                     }
  34.                 }
  35.                 else if (comand == "Update")
  36.                 {
  37.                     if (Games.Contains(game) == true)
  38.                     {
  39.                         Games.Remove(game);
  40.                         Games.Add(game);
  41.                     }
  42.  
  43.                 }
  44.                 else if (comand == "Expansion")
  45.                 {
  46.                     string[] tok = game.Split('-');
  47.                     string gameName = tok[0];
  48.                     string expansion = tok[1];
  49.  
  50.                    if (Games.Contains(gameName))
  51.                    {
  52.                         int indexOfGame = Games.IndexOf(gameName);
  53.                         string gameExpansion = game.Replace('-', ':');
  54.                         if (indexOfGame == Games.Capacity - 1)
  55.                         {
  56.                             Games.Add(gameExpansion);
  57.                         }
  58.                         else
  59.                         {
  60.                             Games.Insert(indexOfGame + 1, gameExpansion);
  61.                         }
  62.  
  63.                    }
  64.                 }
  65.  
  66.                 line = Console.ReadLine();
  67.             }
  68.  
  69.             Console.WriteLine(string.Join(" ", Games));
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement