Advertisement
Guest User

Untitled

a guest
May 22nd, 2020
1,481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp4
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var inputSongs = Console.ReadLine().Split(", ").ToList();
  12.             var songsQueue = new Queue<string>();
  13.  
  14.             foreach (var song in inputSongs)
  15.             {
  16.                 songsQueue.Enqueue(song);
  17.             }
  18.  
  19.             while (songsQueue.Any())
  20.             {
  21.                 var command = Console.ReadLine();
  22.  
  23.                 if (command == "Play")
  24.                 {
  25.                     songsQueue.Dequeue();
  26.                 }
  27.                 else if (command.StartsWith("Add"))
  28.                 {
  29.                     var songFullname = command.Substring(4);
  30.                     if (songsQueue.Contains(songFullname))
  31.                     {
  32.                         Console.WriteLine($"{songFullname} is already contained! ");
  33.                     }
  34.                     else
  35.                     {
  36.                         songsQueue.Enqueue(songFullname);
  37.                     }
  38.                 }
  39.                 else if (command == "Show")
  40.                 {
  41.                     Console.WriteLine("{0}", string.Join(", ", songsQueue));
  42.                 }
  43.             }
  44.  
  45.             Console.WriteLine("No more songs!");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement