Advertisement
Guest User

Untitled

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