Advertisement
silvana1303

wizard poker

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