Advertisement
alexbancheva

Songs_Classes_and_Objects_Lab

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