Advertisement
Spocoman

03. Songs

Mar 2nd, 2022
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Program
  6. {
  7.     class Song
  8.     {
  9.         public string Type { get; set; }
  10.         public string Name { get; set; }
  11.         public string Time { get; set; }
  12.  
  13.         static void Main(string[] args)
  14.         {
  15.             int number = int.Parse(Console.ReadLine());
  16.  
  17.             List<Song> playlist = new List<Song>();
  18.  
  19.             for (int i = 0; i < number; i++)
  20.             {
  21.                 string[] data = Console.ReadLine().Split('_').ToArray();
  22.  
  23.                 string type = data[0];
  24.                 string name = data[1];
  25.                 string time = data[2];
  26.  
  27.                 Song song = new Song();
  28.  
  29.                 song.Name = name;
  30.                 song.Type = type;
  31.                 song.Time = time;
  32.  
  33.                 playlist.Add(song);
  34.             }
  35.             string typeList = Console.ReadLine();
  36.  
  37.             if (typeList == "all")
  38.             {
  39.                 foreach (Song song in playlist)
  40.                 {
  41.                     Console.WriteLine(song.Name);
  42.                 }
  43.             }
  44.             else
  45.             {
  46.                 foreach (Song song in playlist)
  47.                 {
  48.                     if (song.Type == typeList)
  49.                     {
  50.                         Console.WriteLine(song.Name);
  51.                     }
  52.                 }
  53.             }
  54.         }
  55.     }
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement