Advertisement
silvana1303

songs

Oct 11th, 2020 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace classes
  6. {
  7.     class Songs
  8.     {
  9.         public string TypeList { get; set; }
  10.         public string Name { get; set; }
  11.         public string Time { get; set; }
  12.     }
  13.  
  14.     class Program
  15.     {
  16.         static void Main(string[] args)
  17.         {
  18.             int songsCount = int.Parse(Console.ReadLine());
  19.  
  20.             List<Songs> list = new List<Songs>();
  21.  
  22.             for (int i = 0; i < songsCount; i++)
  23.             {
  24.                 string[] input = Console.ReadLine().Split("_").ToArray();
  25.  
  26.                 string type = input[0];
  27.                 string name = input[1];
  28.                 string time = input[2];
  29.  
  30.                 Songs song = new Songs();
  31.  
  32.                 song.TypeList = type;
  33.                 song.Name = name;
  34.                 song.Time = time;
  35.  
  36.                 list.Add(song);
  37.             }
  38.  
  39.             string filter = Console.ReadLine();
  40.  
  41.             if (filter == "all")
  42.             {
  43.                 foreach (var song in list)
  44.                 {
  45.                     Console.WriteLine(song.Name);
  46.                 }
  47.             }
  48.             else
  49.             {
  50.                 List<Songs> filtered = list.Where(x => x.TypeList == filter).ToList();
  51.                 foreach (var song in filtered)
  52.                 {
  53.                     Console.WriteLine(song.Name);
  54.                 }
  55.             }
  56.  
  57.            
  58.         }
  59.  
  60.        
  61.     }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement