Advertisement
Guest User

WizardPoker

a guest
Apr 6th, 2020
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6.  
  7. namespace WizardPoker
  8. {
  9.     class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.  
  14.             List<string> cards = Console.ReadLine().Split(':').ToList();
  15.             List<string> newDeck = new List<string>();
  16.             string command;
  17.             while ((command = Console.ReadLine()) != "Ready")
  18.             {
  19.                 string[] operation = command.Split();
  20.                 if (operation[0] == "Add")
  21.                 {
  22.                     string cardName = operation[1];
  23.                     if (cards.Contains(cardName))
  24.                     {
  25.                         newDeck.Add(cardName);
  26.                     }
  27.                     else
  28.                     {
  29.                         Console.WriteLine("Card not found.");
  30.                     }
  31.                 }
  32.                 else if (operation[0] == "Insert")
  33.                 {
  34.                     string cardName = operation[1];
  35.                     int index = int.Parse(operation[2]);
  36.                     if (cards.Contains(cardName) && (index >= 0 && index <= cards.Count - 1) && index <= newDeck.Count - 1)
  37.                     {
  38.                         newDeck.Insert(index, cardName);
  39.                     }
  40.                     else
  41.                     {
  42.                         Console.WriteLine("Error!");
  43.                     }
  44.                 }
  45.                 else if (operation[0] == "Remove")
  46.                 {
  47.                     string cardName = operation[1];
  48.                     if (newDeck.Contains(cardName))
  49.                     {
  50.                         newDeck.Remove(cardName);
  51.                     }
  52.                     else
  53.                     {
  54.                         Console.WriteLine("Card not found.");
  55.                     }
  56.                 }
  57.                 else if (operation[0] == "Swap")
  58.                 {
  59.                     string card1 = operation[1];
  60.                     string card2 = operation[2];
  61.                     int card1Index = newDeck.IndexOf(card1);
  62.                     int card2Index = newDeck.IndexOf(card2);
  63.  
  64.                     string temp = newDeck[card1Index];
  65.                     newDeck[card1Index] = newDeck[card2Index];
  66.                     newDeck[card2Index] = temp;
  67.                 }
  68.                 else if (operation[0] == "Shuffle")
  69.                 {
  70.                     newDeck.Reverse();
  71.                 }
  72.             }
  73.             Console.WriteLine(string.Join(" ", newDeck));
  74.         }
  75.     }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement