Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _03_Wizard_Poker
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> arsenalCards = Console.ReadLine().Split(":").ToList();
- List<string> commands = Console.ReadLine().Split(" ").ToList();
- List<string> deckCards = new List<string>();
- string command = commands[0];
- string card = commands[1];
- while (command != "Ready")
- {
- switch (command)
- {
- case "Add":
- if (arsenalCards.Contains(card))
- {
- deckCards.Add(card);
- break;
- }
- else
- {
- Console.WriteLine("Card not found.");
- break;
- }
- case "Insert":
- int index = int.Parse(commands[2]);
- if (arsenalCards.Contains(card))
- {
- deckCards.Insert(index, card);
- break;
- }
- else
- {
- Console.WriteLine("Error!");
- break;
- }
- case "Remove":
- if (deckCards.Contains(card))
- {
- deckCards.Remove(card);
- break;
- }
- else
- {
- Console.WriteLine("Card not found.");
- break;
- }
- case "Swap":
- string card2 = commands[2];
- int index1Card = deckCards.IndexOf(card);
- int index2Card = deckCards.IndexOf(card2);
- deckCards[index1Card] = card2;
- deckCards[index2Card] = card;
- break;
- case "Shuffle":
- deckCards.Reverse();
- break;
- }
- commands = Console.ReadLine().Split(" ").ToList();
- command = commands[0];
- if (command == "Ready")
- {
- break;
- }
- else
- {
- card = commands[1];
- }
- }
- Console.WriteLine(string.Join(" ", deckCards));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement