Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Exam_03
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> myList = Console.ReadLine()
- .Split(":")
- .ToList();
- List<string> newList = new List<string>();
- string input = Console.ReadLine();
- while (input != "Ready")
- {
- string[] actions = input.Split(" ");
- string command = actions[0];
- if (command == "Add")
- {
- string nameCard = actions[1];
- if (myList.Contains(nameCard))
- {
- newList.Add(nameCard);
- }
- else
- {
- Console.WriteLine("Card not found.");
- }
- }
- else if (command == "Insert")
- {
- string name = actions[1];
- int index = int.Parse(actions[2]);
- if (index >= 0 && index < myList.Count)
- {
- if (myList.Contains(name))
- {
- newList.Insert(index, name);
- }
- else
- {
- Console.WriteLine("Error!");
- }
- }
- else
- {
- Console.WriteLine("Error!");
- }
- }
- else if (command == "Remove")
- {
- string cardName = actions[1];
- if (newList.Contains(cardName))
- {
- newList.Remove(cardName);
- }
- else
- {
- Console.WriteLine("Card not found.");
- }
- }
- else if (command == "Swap")
- {
- string firstWord = actions[1];
- string secondWord = actions[2];
- if (newList.Contains(firstWord) && secondWord.Contains(secondWord)) // dali syshestvuwat dumite
- {
- int firstWordInex = newList.IndexOf(firstWord);
- int secondtWordInex = newList.IndexOf(secondWord); // namirame na koi index sa dumite
- newList[firstWordInex] = secondWord;
- newList[secondtWordInex] = firstWord;
- }
- }
- else if (command == "Shuffle")
- {
- if (actions[1] == "deck")
- {
- newList.Reverse();
- }
- }
- input = Console.ReadLine();
- }
- Console.WriteLine(string.Join(" ", newList));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement