Example #1
0
        static void Main()
        {
            var      numberOfSongs = int.Parse(Console.ReadLine());
            Playlist playlist      = new Playlist();

            for (int i = 0; i < numberOfSongs; i++)
            {
                try
                {
                    var song = Console
                               .ReadLine()
                               .Split(";", StringSplitOptions.RemoveEmptyEntries);

                    SongValidator.Song(song);

                    Track track = new Track(song[0], song[1], song[2]);

                    Console.WriteLine("Song added.");
                    playlist.Add(track);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            Console.WriteLine(playlist);
        }
Example #2
0
        static void Main(string[] args)
        {
            Track track = new Track();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');

                try
                {
                    SongValidator.Song(input);

                    string artist = input[0];
                    string song   = input[1];
                    string length = input[2];

                    SongValidator.Artist(artist);
                    SongValidator.Song(song);
                    SongValidator.SongLength(length);
                    track.AddSong(length);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine(ex.Message);
                }
            }
        }