static void Main(string[] args) { int songs = int.Parse(Console.ReadLine()); InvalidSongException ex = new InvalidSongException(); InvalidArtistNameException exA = new InvalidArtistNameException(); InvalidSongNameException exN = new InvalidSongNameException(); InvalidSongLengthException exL = new InvalidSongLengthException(); InvalidSongMinutesException exSM = new InvalidSongMinutesException(); InvalidSongSecondsException exSE = new InvalidSongSecondsException(); for (int i = 0; i < songs; i++) { string[] tokens = Console.ReadLine().Split(';'); if (tokens.Length != 3) { Console.WriteLine(ex.Message); } string artist = tokens[0]; string songName = tokens[1]; TimeSpan ts = TimeSpan.ParseExact(tokens[2], @"hh\:mm", CultureInfo.CurrentCulture); } }
private static List <InvalidSongException> GetPlaylist() { var numberOfSongs = int.Parse(Console.ReadLine()); var playlist = new List <InvalidSongException>(); for (int i = 0; i < numberOfSongs; i++) { try { var songInfo = Console.ReadLine() .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); var artistName = songInfo[0]; var songName = songInfo[1]; List <int> songDuration; try { songDuration = songInfo[2] .Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse) .ToList(); } catch { throw new ArgumentException("Invalid song length."); } var song = new InvalidSongException(artistName, songName, songDuration[0], songDuration[1]); playlist.Add(song); Console.WriteLine("Song added."); } catch (Exception e) { Console.WriteLine(e.Message); } } return(playlist); }