Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using System.Text;
- namespace fundamental14
- {
- class MainClass
- {
- public static void Main()
- {
- List<string> card = Console.ReadLine().Split(":").ToList();
- List<string> cardN = new List<string>();
- string input = string.Empty;
- while((input = Console.ReadLine())!= "Ready")
- {
- string[] array = input.Split().ToArray();
- string command = array[0];
- string cardName = array[1];
- int indexRem = 0;
- if (command == "Add")
- {
- if(!card.Contains(cardName))
- {
- Console.WriteLine("Card not found.");
- }
- else
- {
- indexRem = card.IndexOf(cardName);
- cardN.Add(cardName);
- card.RemoveAt(indexRem);
- }
- }
- else if (command == "Insert")
- {
- int index = int.Parse(array[2]);
- if (index >= 0 && index < cardN.Count && card.Contains(cardName))
- {
- indexRem = card.IndexOf(cardName);
- card.RemoveAt(indexRem);
- cardN.Insert(index, cardName);
- }
- else
- {
- Console.WriteLine("Error!");
- }
- }
- else if (command == "Remove")
- {
- if (cardN.Contains(cardName))
- {
- indexRem = cardN.IndexOf(cardName);
- cardN.RemoveAt(indexRem);
- }
- else
- {
- Console.WriteLine("Card not found.");
- }
- }
- else if (command == "Swap")
- {
- string word2 = array[2];
- indexRem = cardN.IndexOf(cardName);
- int newIndex = cardN.IndexOf(word2);
- if (indexRem > newIndex)
- {
- cardN.Insert(indexRem, word2);
- cardN.RemoveAt(indexRem + 1);
- cardN.Insert(newIndex, cardName);
- cardN.RemoveAt(newIndex + 1);
- }
- else
- {
- cardN.Insert(newIndex, cardName);
- cardN.RemoveAt(newIndex + 1);
- cardN.Insert(indexRem, word2);
- cardN.RemoveAt(indexRem + 1);
- }
- }
- else if (command == "Shuffle")
- {
- cardN.Reverse();
- }
- }
- Console.WriteLine(string.Join(" ", cardN));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement