Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. namespace Problem_6.Songs_Queue
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. class Program
  10. {
  11. static void Main()
  12. {
  13. var inputSongs = Console.ReadLine()
  14. .Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
  15. .ToArray();
  16. var songQueue = new Queue<string>(inputSongs);
  17.  
  18. while (songQueue.Count > 0)
  19. {
  20. var command = Console.ReadLine().Split(new char[] { ' ' }, 2).ToArray();
  21.  
  22. if (command[0] == "Play")
  23. {
  24. songQueue.Dequeue();
  25. }
  26.  
  27. else if (command[0] == "Add")
  28. {
  29. if (songQueue.Contains(command[1]))
  30. {
  31. Console.WriteLine($"{command[1]} is already contained!");
  32. }
  33. else
  34. {
  35. songQueue.Enqueue(command[1]);
  36. }
  37. }
  38. else if (command[0] == "Show")
  39. {
  40. Console.WriteLine(String.Join(", ", songQueue));
  41. }
  42.  
  43. }
  44. Console.WriteLine("No more songs!");
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement