Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _03_Wizard_Poker
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<string> arsenalCards = Console.ReadLine().Split(":").ToList();
  12.  
  13.             List<string> commands = Console.ReadLine().Split(" ").ToList();
  14.  
  15.             List<string> deckCards = new List<string>();
  16.  
  17.             string command = commands[0];
  18.             string card = commands[1];
  19.  
  20.             while (command != "Ready")
  21.             {
  22.                 switch (command)
  23.                 {
  24.                     case "Add":
  25.  
  26.                         if (arsenalCards.Contains(card))
  27.                         {
  28.                             deckCards.Add(card);
  29.                             break;
  30.                         }
  31.                         else
  32.                         {
  33.                             Console.WriteLine("Card not found.");
  34.                             break;
  35.                         }
  36.                     case "Insert":
  37.  
  38.                         int index = int.Parse(commands[2]);
  39.  
  40.                         if (arsenalCards.Contains(card))
  41.                         {
  42.                             deckCards.Insert(index, card);
  43.                             break;
  44.                         }
  45.                         else
  46.                         {
  47.                             Console.WriteLine("Error!");
  48.                             break;
  49.                         }
  50.                     case "Remove":
  51.  
  52.                         if (deckCards.Contains(card))
  53.                         {
  54.                             deckCards.Remove(card);
  55.                             break;
  56.                         }
  57.                         else
  58.                         {
  59.                             Console.WriteLine("Card not found.");
  60.                             break;
  61.                         }
  62.                     case "Swap":
  63.  
  64.                         string card2 = commands[2];
  65.                        
  66.                         int index1Card = deckCards.IndexOf(card);
  67.                         int index2Card = deckCards.IndexOf(card2);
  68.  
  69.                         deckCards[index1Card] = card2;
  70.                         deckCards[index2Card] = card;
  71.                         break;
  72.                     case "Shuffle":
  73.  
  74.                         deckCards.Reverse();
  75.                         break;
  76.                 }
  77.  
  78.                 commands = Console.ReadLine().Split(" ").ToList();
  79.                 command = commands[0];
  80.  
  81.                 if (command == "Ready")
  82.                 {
  83.                     break;
  84.                 }
  85.  
  86.                 else
  87.                 {
  88.                     card = commands[1];
  89.                 }
  90.             }
  91.  
  92.             Console.WriteLine(string.Join(" ", deckCards));
  93.         }
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement