Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04Songs
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberOfSongs = int.Parse(Console.ReadLine());
- List<Song> songs = new List<Song>();
- for (int i = 1; i <= numberOfSongs; i++)
- {
- var data = Console.ReadLine().Split("_");
- string type = data[0]; // set the type of song
- string name = data[1]; // set the name of song
- string time = data[2]; // set the time of song
- Song song = new Song(type, name, time); // create new object from the class Song
- songs.Add(song);
- }
- string typeList = Console.ReadLine();
- string result = string.Empty;
- if (typeList == "all")
- {
- result += string.Join("\n", songs.Select(x => x.Name));
- }
- result += string.Join("\n", songs.Where(x => x.TypeList == typeList).Select(x => x.Name));
- Console.WriteLine(result);
- }
- }
- class Song
- {
- // fields
- public string TypeList { get; set; }
- public string Name { get; set; }
- public string Time { get; set; }
- public Song(string typeList, string name, string time) // constructor
- {
- TypeList = typeList;
- Name = name;
- Time = time;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement