Exemple #1
0
        private static void Task10()
        {
            // - print the name of the
            //artist that has most songs

            //aggregation of songs accross
            //all albums on foot
            //var allSongs = new List<Song>();
            //foreach (var album in Albums)
            //{
            //    allSongs.AddRange(album.Songs);
            //}

            //aggregation of songs accross
            //all albums of an artist
            //on foot
            //var allSongsOfArtist = new List<Song>();
            //int artistId = 1;
            //var albumsOfArtist =
            //    Albums
            //    .Where(album => album.ArtistId == artistId);

            //foreach (var album in albumsOfArtist)
            //{
            //    allSongsOfArtist.AddRange(album.Songs);
            //}
            //int songsCountForArtist = allSongsOfArtist.Count;

            var artistWithMostSongs =
                Artists.OrderByDescending(
                    artist => artist.Albums.SelectMany(album => album.Songs).Count())
                .FirstOrDefault();

            Console.WriteLine(artistWithMostSongs.FullName);
        }
Exemple #2
0
 /// <summary>
 /// Changes Artists ListView sort order.
 /// </summary>
 /// <param name="sender"></param>
 public void SortArtistsView(object sender, ref string lastArtistHeaderClicked, ref ListSortDirection lastArtistDirection)
 {
     SortListView(sender, ref lastArtistHeaderClicked, ref lastArtistDirection, "Name");
     LastArtistDirectionText = lastArtistDirection == ListSortDirection.Ascending ? "A-Z" : "Z-A";
     Artists = (lastArtistDirection == ListSortDirection.Ascending
         ? Artists.OrderBy(i => i.Name)
         : Artists.OrderByDescending(i => i.Name)).ToList();
     OnPropertyChanged("LastArtistDirectionText");
 }
Exemple #3
0
        private static void Task11()
        {
            // - print the type of the
            //artist(SoloArtist/Band)
            //that has most albums
            //published before year 2000
            var result = Artists.OrderByDescending(
                artist => artist.Albums.Count(
                    album => album.Year < 2000
                    )
                )
                         .FirstOrDefault();

            result.ArtistType.PrintItem();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!

            // - how many Songs start with the letter 'a' (case insensitive)
            // - how many artists end with letter 'a' (case insensitive)
            // - whats the name of the song with longest duration
            // - whats the total Duration of all Songs
            // - how many albums have Songs longer than 300 seconds
            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            // - print the name of the album that has highest Average duration of a song
            // - how many characters has the song that has the shortest Duration
            // - print the name and the genre of the album that has most songs
            // - print the name of the artist that has most songs
            // - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            // - print the average song duration, of the album that has most songs

            // Bonus:
            // - print the longest song duration of the album that has least songs
            // - print the name of the album that has most songs that contain letter 'a' in the name
            // - print the name of the artist that has most songs that end with letter 'd'



            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)


            // - how many Songs start with the letter 'a' (case insensitive)
            int songsStartWithA = Songs.Where(s => s.Name.ToLower().StartsWith('a')).Count();

            Console.WriteLine($"{songsStartWithA} songs start with letter 'a'");


            // - how many artists end with letter 'a' (case insensitive)
            int artistsEndsWithA = Artists.Where(a => a.FullName.ToLower().EndsWith('a')).Count();

            Console.WriteLine($"{artistsEndsWithA} artists ends with letter 'a'");


            // - whats the name of the song with longest duration
            string longestSongName = Songs.OrderBy(s => s.Duration).Last().Name;

            Console.WriteLine($"{longestSongName} is the longest song");


            // - whats the total Duration of all Songs
            int allSongsDuration = Songs.Sum(s => s.Duration);

            Console.WriteLine($"The duration of all songs is {allSongsDuration}");


            // - how many albums have Songs longer than 300 seconds
            int count = 0;

            foreach (var album in Albums)
            {
                int songs = album.Songs.Where(s => s.Duration >= 300).Count();
                if (songs > 0)
                {
                    count++;
                }
            }
            Console.WriteLine("Martin: " + count);

            int albumsHaveSongsLongerThan300seconds = Albums.Where(x => x.Songs.Any(y => y.Duration > 300)).Count();

            Console.WriteLine("Stefan: " + albumsHaveSongsLongerThan300seconds);

            var songsLongerThan = Albums.Where(x => x.Songs.Max(y => y.Duration > 300)).Select(x => x.Name).Count();

            Console.WriteLine("Kiko: " + songsLongerThan);



            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            List <Artist> artistsWithMoreThanOnePopRockAlbum =
                Artists
                .Where(a => a.Albums.Where(al => al.Genre == Genre.PopRock).Count() > 1)
                .ToList();

            Console.WriteLine("Artists that have more than one album of PopRock genre");
            artistsWithMoreThanOnePopRockAlbum.ForEach(a => Console.WriteLine($"{a.FullName} -- "));



            // - print the name of the album that has highest Average duration of a songs
            string highestAverageDurationAlubm = Albums.OrderByDescending(a => a.Songs.Average(s => s.Duration)).First().Name;

            //string highestAverageDurationAlubm = Albums
            //                                    .OrderByDescending(a => a.Songs.Average(s => s.Duration))
            //                                    .Select(a => a.Name)
            //                                    .FirstOrDefault();

            Console.WriteLine($"The name of the album with highest average duration of songs is {highestAverageDurationAlubm}");



            // - how many characters has the song that has the shortest Duration
            int    shortestDuration = Songs.Min(s => s.Duration);
            string shortestSongName = Songs
                                      .Where(s => s.Duration == shortestDuration)
                                      .Select(s => s.Name)
                                      .FirstOrDefault();
            int shortestSongCharacterLength = Songs
                                              .Where(s => s.Duration == shortestDuration)
                                              .Select(s => s.Name)
                                              .FirstOrDefault()
                                              .Length;

            Console.WriteLine($"Song: {shortestSongName} | Length of chars: {shortestSongCharacterLength}");



            //print the type of the artist(SoloArtist/ Band) that has most albums published before year 2000


            ArtistType artistWithMostAlbumsPublishedBefore2000 = Artists
                                                                 .OrderByDescending(x => x.Albums.Any(y => y.Year < 2000))
                                                                 .Select(x => x.ArtistType)
                                                                 .FirstOrDefault();


            ArtistType typeOfArtist = Artists
                                      .OrderByDescending(x => x.Albums.Count(y => y.Year < 2000))
                                      .Select(x => x.ArtistType)
                                      .FirstOrDefault();

            Console.WriteLine(artistWithMostAlbumsPublishedBefore2000);
            Console.WriteLine(typeOfArtist);


            // - print the average song duration, of the album that has most songs

            var averageSongDuration = Albums.OrderByDescending(a => a.Songs.Count)
                                      .Select(a => a.Songs.Average(s => s.Duration))
                                      .FirstOrDefault();

            Console.WriteLine(averageSongDuration);



            // Bonus:
            // - print the longest song duration of the album that has least songs



            //TODO: Double check this
            //var longestSong =  Albums
            //                  .OrderBy(a => a.Songs.Count)
            //                  .Select(a => new { Name = a.Name, Duration = a.Songs.Max(s => s.Duration) })
            //                  .FirstOrDefault();

            //Console.WriteLine($"Duration: {longestSong.Duration} | Name: {longestSong.Name}");


            int longestSongDurationOfTheAlbumWithTheLeastSongs = Albums
                                                                 .OrderByDescending(x => x.Songs.Count)
                                                                 .Select(y => y.Songs.Max(x => x.Duration))
                                                                 .LastOrDefault();


            // - print the name of the album that has most songs that contain letter 'a' in the name
            var albumWithMostSongsContainLetterA = Albums
                                                   .OrderByDescending(a => a.Songs.Count(s => s.Name.Contains('a')))
                                                   .Select(x => x.Name)
                                                   .FirstOrDefault();



            Console.WriteLine(albumWithMostSongsContainLetterA);



            // - print the name of the artist that has most songs that end with letter 'd'
            string artistNameWithMostSongsEndWithLetterD = Artists
                                                           .OrderByDescending(x => x.Albums.Count(y => y.Songs.Any(z => z.Name.EndsWith('d'))))
                                                           .Select(x => x.FullName)
                                                           .FirstOrDefault();

            Console.WriteLine(artistNameWithMostSongsEndWithLetterD);

            string artistsWithMostDs = Artists
                                       .OrderByDescending(x => x.Albums.Max(y => y.Songs.Count(z => z.Name.EndsWith('d'))))
                                       .Select(x => x.FullName)
                                       .FirstOrDefault();

            Console.WriteLine(artistsWithMostDs);



            Console.ReadLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!

            // - how many Songs start with the letter 'a' (case insensitive)
            Console.WriteLine("==================================================================================");
            int songsStartsWithA = Songs.Where(a => a.Name.StartsWith('a')).ToList().Count;

            Console.WriteLine("Songs start with the letter \"a\"", songsStartsWithA);
            Console.WriteLine("==================================================================================");
            // - how many artists end with letter 'a' (case insensitive)
            int artistEndsWithA = Artists.Where(a => a.FullName.EndsWith('a')).ToList().Count;

            Console.WriteLine("Artists end with letter \"a\"{0}", artistEndsWithA);
            Console.WriteLine("==================================================================================");
            // - whats the name of the song with longest duration
            string songWithLongesDuration = Songs.OrderByDescending(x => x.Duration).FirstOrDefault().Name;

            Console.WriteLine("Name of the song with longest duration: {0}", songWithLongesDuration);
            Console.WriteLine("==================================================================================");
            // - whats the total Duration of all Songs
            int totalDurationOfAllSongs = Songs.Sum(a => a.Duration);

            Console.WriteLine("Total Duration of all Songs {0}min", totalDurationOfAllSongs / 60);
            Console.WriteLine("==================================================================================");
            // - how many albums have Songs longer than 300 seconds
            // Test nesto se gubam :D :D :D
            //List<Album> albumsHaveSongsLongerThan300seconds = new List<Album>();
            //foreach (var album in Albums)
            //{
            //    foreach (var song in album.Songs)
            //    {
            //        if (song.Duration > 300)
            //        {
            //            albumsHaveSongsLongerThan300seconds.Add(album);
            //            break;
            //        }
            //    }
            //}
            //Console.WriteLine("{0} albums have Songs longer than 300 seconds", albumsHaveSongsLongerThan300seconds.Count);
            //Testiram dali raboti kako sto treba
            //foreach (var item in albumsHaveSongsLongerThan300seconds)
            //{
            //    Console.WriteLine(item);
            //}
            int albumsHaveSongsLongerThan300seconds = Albums.Where(x => x.Songs.Any(y => y.Duration > 300)).Count();

            Console.WriteLine("{0} albums have Songs longer than 300 seconds", albumsHaveSongsLongerThan300seconds);
            Console.WriteLine("==================================================================================");
            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            List <Artist> artistsWithMoreThenOneAlbumPopRock = Artists.Where(x => x.Albums.Any(y => y.Genre.Equals(Genre.PopRock))).ToList();

            Console.WriteLine("Artists that have more than one album of PopRock genre: ");
            foreach (var artist in artistsWithMoreThenOneAlbumPopRock)
            {
                Console.WriteLine("Artist: " + artist.FullName);
                Console.WriteLine("------------------------------------");
            }
            Console.WriteLine("==================================================================================");
            // - print the name of the album that has highest Average duration of a song
            string albumNameWithHighestAverageDurationSong = Albums.OrderByDescending(x => x.Songs.Average(y => y.Duration)).Select(x => x.Name).FirstOrDefault();

            Console.WriteLine("Album that has highest Average duration of a song: {0}", albumNameWithHighestAverageDurationSong);
            Console.WriteLine("==================================================================================");
            // - how many characters has the song that has the shortest Duration
            int songWithShortestDurationInCharacters = Songs.OrderByDescending(x => x.Duration).Select(x => x.Name).LastOrDefault().ToCharArray().Length;

            Console.WriteLine("Song that has the shortest Duration has {0} characters", songWithShortestDurationInCharacters);
            Console.WriteLine("==================================================================================");
            // - print the name and the genre of the album that has most songs
            //var albumWithTheMostSongs = Albums.OrderByDescending(x => x.Songs.Count).Select(x => new { x.Name, x.Genre }).FirstOrDefault();
            Album albumWithTheMostSongs = Albums.OrderByDescending(x => x.Songs.Count).FirstOrDefault();

            Console.WriteLine("Album that has most songs:");
            Console.WriteLine("Name: {0}", albumWithTheMostSongs.Name);
            Console.WriteLine("Genre: {0}", albumWithTheMostSongs.Genre);
            Console.WriteLine("==================================================================================");
            // - print the name of the artist that has most songs
            string artistThatHasMostSongs = Artists.OrderByDescending(x => x.Albums.Sum(y => y.Songs.Count)).Select(x => x.FullName).FirstOrDefault();

            Console.WriteLine("Artist that has most songs: {0}", artistThatHasMostSongs);
            Console.WriteLine("==================================================================================");
            // - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            ArtistType artistWithMostAlbumsPublishedBefore2000 = Artists.OrderByDescending(x => x.Albums.Any(y => y.Year < 2000)).Select(x => x.ArtistType).FirstOrDefault();

            Console.WriteLine("{0} has most albums published before year 2000", artistWithMostAlbumsPublishedBefore2000);
            Console.WriteLine("==================================================================================");
            // - print the average song duration, of the album that has most songs
            double avarageSongDurationOfAlbumThatHasMostSongs = albumWithTheMostSongs.Songs.Average(x => x.Duration);

            Console.WriteLine("Average song duration of the album that has most songs is {0}min", avarageSongDurationOfAlbumThatHasMostSongs / 60);
            Console.WriteLine("==================================================================================");
            // Bonus:
            // - print the longest song duration of the album that has least songs
            int longestSongDurationOfAlbumWithLeastSongs = Albums.OrderByDescending(x => x.Songs.Count).FirstOrDefault().Songs.Max(x => x.Duration);

            Console.WriteLine("longest song duration of the album that has least songs is: " + longestSongDurationOfAlbumWithLeastSongs);
            Console.WriteLine("==================================================================================");
            // - print the name of the album that has most songs that contain letter 'a' in the name
            //string albumWithMostSongsThatContainAInName = Albums.OrderByDescending(x => x.Songs.Sum(y => y.Name.Take('a').Count())).Select(x => x.Name).FirstOrDefault();
            //string albumWithMostSongsThatContainAInName = Albums.OrderByDescending(x => x.Songs.Where(y => y.Name.Contains('a')).Count()).Select(x => x.Name).FirstOrDefault();
            string albumWithMostSongsThatContainAInName = Albums.OrderByDescending(x => x.Songs.Count(y => y.Name.Contains('a'))).Select(x => x.Name).FirstOrDefault();

            Console.WriteLine("album that has most songs that contain letter 'a' in the name is: " + albumWithMostSongsThatContainAInName);
            Console.WriteLine("==================================================================================");
            // - print the name of the artist that has most songs that end with letter 'd'
            string artistNameWithMostSongsEndWithLetterD = Artists.OrderByDescending(x => x.Albums.Count(y => y.Songs.Any(z => z.Name.EndsWith('d')))).Select(x => x.FullName).FirstOrDefault();

            //string artistNameWithMostSongsEndWithLetterD = Artists.OrderByDescending(x => x.Albums.Count(y => y.Songs.Max(z => z.Name.EndsWith('d')))).Select(x => x.FullName).FirstOrDefault();
            //string artistNameWithMostSongsEndWithLetterD = Artists.OrderByDescending(x => x.Albums.Max(y => y.Songs.Count(z => z.Name.EndsWith('d')))).Select(x => x.FullName).FirstOrDefault();
            Console.WriteLine("Name of the artist that has most songs that end with letter 'd' is: {0}", artistNameWithMostSongsEndWithLetterD);
            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************
            // 3, 2, 1.... GO! :)
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!

            // - how many Songs start with the letter 'a' (case insensitive) /
            // - how many artists end with letter 'a' (case insensitive) /
            // - whats the name of the song with longest duration /
            // - whats the total Duration of all Songs /
            // - how many albums have Songs longer than 300 seconds /
            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre /
            // - print the name of the album that has highest Average duration of a song /
            // - how many characters has the song that has the shortest Duration /
            // - print the name and the genre of the album that has most songs /
            // - print the name of the artist that has most songs /
            // - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000 /
            // - print the average song duration, of the album that has most songs /

            // Bonus:
            // - print the longest song duration of the album that has least songs /
            // - print the name of the album that has most songs that contain letter 'a' in the name /
            // - print the name of the artist that has most songs that end with letter 'd' /



            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)

            List <Song> songsStartingWithA = Songs.Where(x => x.Name.StartsWith('A')).ToList();

            Console.WriteLine(@"Songs starting with ""a"": {0}", songsStartingWithA.Count);
            songsStartingWithA.ForEach(x => Console.WriteLine(x.Name));

            Console.WriteLine("=======================================");

            List <Artist> artistsEndingWithA = Artists.Where(x => x.FullName.EndsWith('a')).ToList();

            Console.WriteLine(@"Artists ending with ""a"": {0}", artistsEndingWithA.Count);
            artistsEndingWithA.ForEach(x => Console.WriteLine(x.FullName));

            Console.WriteLine("=======================================");

            string songWithLongestDuration = Songs.OrderByDescending(x => x.Duration)
                                             .Take(1)
                                             .Select(x => x.Name)
                                             .ToString();

            Console.WriteLine("The song with the longest duration is: {0}", songWithLongestDuration);

            Console.WriteLine("=======================================");

            int totalSongDuration = Songs.Sum(x => x.Duration);

            Console.WriteLine("The total duration of all the song is {0} minutes.", totalSongDuration / 60);

            Console.WriteLine("=======================================");

            List <Album> albumsWithSongsOver300 = Albums.Where(x => x.Songs.Any(y => y.Duration > 300)).ToList();

            Console.WriteLine("The count of the albums with song duration over 300 seconds is: {0}", albumsWithSongsOver300.Count());

            Console.WriteLine("=======================================");

            List <string> artistsWithPopRockAlbums = Artists.Where(x => x.Albums.Any(y => y.Genre.Equals(Genre.PopRock))).Select(x => x.FullName).ToList();

            foreach (var name in artistsWithPopRockAlbums)
            {
                Console.WriteLine("Artist: {0}", name);
                Console.WriteLine("----------------------------");
            }

            Console.WriteLine("=======================================");

            string albumWithTheHighestAvrDurSong = Albums.OrderByDescending(x => x.Songs.Average(a => a.Duration)).FirstOrDefault().Name;

            Console.WriteLine(albumWithTheHighestAvrDurSong);

            Console.WriteLine("=======================================");

            char[] charsOfSongWithShortestDuration = Songs.OrderBy(x => x.Duration).Select(x => x.Name).FirstOrDefault().ToCharArray();
            Console.WriteLine("The shortest duration song has {0} characters.", charsOfSongWithShortestDuration.Length);

            Console.WriteLine("=======================================");

            var albumWithMostSongs = Albums.OrderByDescending(x => x.Songs.Count).Select(x => new { x.Name, x.Genre }).FirstOrDefault();

            Console.WriteLine("The album with most songs is: Name: {0} | Genre: {1}", albumWithMostSongs.Name, albumWithMostSongs.Genre);

            Console.WriteLine("=======================================");

            string artistWithMostSongs = Artists.OrderByDescending(x => x.Albums.Sum(y => y.Songs.Count)).Select(x => x.FullName).FirstOrDefault();

            Console.WriteLine("The artist with the most songs is: {0}.", artistWithMostSongs);

            Console.WriteLine("=======================================");

            ArtistType typeOfArtistWithMostAlbumsBefore2000 = Artists.OrderByDescending(x => x.Albums.Any(y => y.Year < 2000)).Select(x => x.ArtistType).FirstOrDefault();

            Console.WriteLine("The type of the artist that has the most albums published before the year 2000 is: {0}", typeOfArtistWithMostAlbumsBefore2000);

            Console.WriteLine("=======================================");

            double averageSongDurationOfTheAlbumWithMostSongs = Albums.OrderByDescending(x => x.Songs.Count).Select(x => x.Songs.Average(a => a.Duration)).FirstOrDefault();

            Console.WriteLine("The average song duration of the album with most songs is: {0} minutes.", averageSongDurationOfTheAlbumWithMostSongs / 60);

            Console.WriteLine("=======================================");

            Album albumWIthTheLeastSongs = Albums.OrderBy(x => x.Songs.Count).FirstOrDefault();

            double longestSongOfAlbumWithLeastSongs = albumWIthTheLeastSongs.Songs.OrderByDescending(x => x.Duration).FirstOrDefault().Duration;

            Console.WriteLine("The longest song duration of the album with least songs is: {0} seconds | From the album \"{1}\"", longestSongOfAlbumWithLeastSongs, albumWIthTheLeastSongs.Name);

            Console.WriteLine("=======================================");

            string albumWithTheMostSongsThatContainTheLetterA = Albums.OrderByDescending(x => x.Songs.Where(a => a.Name.Contains('a')).Count()).Select(x => x.Name).FirstOrDefault();

            Console.WriteLine("The name of the album that has most songs that contain the letter 'a' in the name is: {0}", albumWithTheMostSongsThatContainTheLetterA);

            Console.WriteLine("=======================================");

            string nameOfTheArtistWithMostSongsThatEndOnD = Artists.OrderByDescending(x => x.Albums.All(a => a.Songs.Any(z => z.Name.EndsWith('d')))).Select(x => x.FullName).FirstOrDefault();

            Console.WriteLine("The name of the artist that has the most songs ending with the letter 'd' is: \"{0}\"", nameOfTheArtistWithMostSongsThatEndOnD);

            Console.ReadLine();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!

            // 1. how many Songs start with the letter 'a' (case insensitive)


            List <Song> songsWithA = Songs.Where(x => x.Name.StartsWith("A"))
                                     .ToList();

            if (songsWithA.Count == 1)
            {
                Console.WriteLine($"{songsWithA.Count} songs start with letter A:");
            }
            else
            {
                Console.WriteLine($"{songsWithA.Count} songs starts with letter A:");
            }

            songsWithA.ForEach(x => Console.WriteLine(x.Name));

            Console.WriteLine("====================================================================================");

            //// 2. how many artists end with letter 'a' (case insensitive)


            List <Artist> artistWithA = Artists.Where(x => x.FullName.EndsWith("a"))
                                        .ToList();

            if (artistWithA.Count == 1)
            {
                Console.WriteLine($"{artistWithA.Count} artist name ends with letter A:");
            }
            else
            {
                Console.WriteLine($"{artistWithA.Count} artists name ends with letter A:");
            }

            artistWithA.ForEach(x => Console.WriteLine(x.FullName));

            Console.WriteLine("====================================================================================");

            // 3. whats the name of the song with longest duration


            List <string> longestSong = Songs.OrderByDescending(x => x.Duration)
                                        .Take(1)
                                        .Select(x => x.Name)
                                        .ToList();

            longestSong.ForEach(x => Console.WriteLine($"The name of the song with longest duration is: {x}."));

            Console.WriteLine("====================================================================================");

            //4. whats the total Duration of all Songs


            int totalDuration = Songs.Sum(x => x.Duration);

            Console.WriteLine($"Total duration of songs is: {totalDuration} seconds.");

            Console.WriteLine("====================================================================================");

            // 5. how many albums have Songs longer than 300 seconds

            var albumWithLongSongs = Songs.Where(x => x.Duration > 300)
                                     .GroupBy(x => x.AlbumId)
                                     .ToList();

            Console.WriteLine($"There are {albumWithLongSongs.Count} albums with songs longer than 300 seconds.");

            Console.WriteLine("====================================================================================");


            // 6. print the names of the artists(separated with "--"), that have more than one album of PopRock genre

            List <Artist> artistWithPR = new List <Artist>();

            Console.WriteLine("Artist that have more than one PopRock album are:");
            foreach (var artist in Artists)
            {
                var popRockAlbum = artist.Albums.Where(x => x.Genre == Genre.PopRock)
                                   .ToList()
                                   .Count();

                if (popRockAlbum > 1)
                {
                    artistWithPR.Add(artist);
                }
            }

            int total = artistWithPR.Count - 1;

            for (int i = 0; i < artistWithPR.Count; i++)
            {
                if (i == total)
                {
                    Console.Write(artistWithPR[i].FullName);
                }
                else
                {
                    Console.Write(artistWithPR[i].FullName + " == ");
                }
            }

            Console.WriteLine("\n====================================================================================");


            // 7. print the name of the album that has highest Average duration of a song

            var albumHighestAve = Albums.OrderByDescending(x => x.Songs.Average(y => y.Duration))
                                  .Select(x => x.Name)
                                  .FirstOrDefault();

            Console.WriteLine($"{albumHighestAve} is the album with the highest average duration of a song.");

            Console.WriteLine("====================================================================================");

            // 8. how many characters has the song that has the shortest Duration


            Song shortestSong = Songs.OrderBy(x => x.Duration)
                                .FirstOrDefault();

            string songName = shortestSong.Name;
            int    count    = 0;

            for (int i = 0; i < songName.Length; i++)
            {
                if (songName[i] != ' ')
                {
                    count++;
                }
            }


            Console.WriteLine($"The shortest song {shortestSong.Name} has {count} characters.");

            Console.WriteLine("====================================================================================");


            // 9. print the name and the genre of the album that has most songs

            var albumWithMostSongs = Albums.OrderByDescending(x => x.Songs.Count())
                                     .FirstOrDefault();

            Console.WriteLine($"The album {albumWithMostSongs.Name} with genre of {albumWithMostSongs.Genre} music has the most songs.");

            Console.WriteLine("====================================================================================");


            // 10. print the name of the artist that has most songs

            var artistMostSongs = Artists.OrderByDescending(x => x.Albums.Sum(y => y.Songs.Count))
                                  .FirstOrDefault();

            Console.WriteLine($"Artist that has the most songs is {artistMostSongs.FullName}.");

            Console.WriteLine("====================================================================================");


            // 11. print the type of the artist(SoloArtist/Band) that has most albums published before year 2000


            var artistBefore2000 = Artists.OrderByDescending(x => x.Albums.Any(y => y.Year < 2000))
                                   .ToList()
                                   .FirstOrDefault();

            Console.WriteLine($"The artist that has most album published before 2000 is from type {artistBefore2000.ArtistType}.");


            Console.WriteLine("====================================================================================");


            // 12. print the average song duration, of the album that has most songs


            //var albumWithMostSongs = Albums.OrderByDescending(x => x.Songs.Count()).FirstOrDefault(); (od 9 zadaca)
            var songAve = albumWithMostSongs.Songs.Average(x => x.Duration);

            Console.WriteLine($"The average song duration of the album with most songs {albumWithMostSongs.Name} is {songAve} seconds.");

            Console.WriteLine("====================================================================================");


            // Bonus:
            // 13. print the longest song duration of the album that has least songs

            var longestSongShortAlbum = Albums.OrderBy(x => x.Songs.Count())
                                        .FirstOrDefault()
                                        .Songs.OrderByDescending(y => y.Duration)
                                        .ToList();

            Console.WriteLine($"Longest song duration of the album that has least songs is the song {longestSongShortAlbum.FirstOrDefault().Name} with duration of {longestSongShortAlbum.FirstOrDefault().Duration} seconds.");

            Console.WriteLine("====================================================================================");


            // 14. print the name of the album that has most songs that contain letter 'a' in the name

            var albumWithMostAs = Albums.OrderByDescending(x => x.Songs.Where(y => y.Name.Contains('a')).Count())
                                  .ToList()
                                  .FirstOrDefault();

            Console.WriteLine($"The album that has most songs that contain the letter 'a' in the name is {albumWithMostAs.Name}.");

            Console.WriteLine("====================================================================================");

            //// 15. print the name of the artist that has most songs that end with letter 'd'

            var artistsWithMostDs = Artists.OrderByDescending(x => x.Albums.Max(y => y.Songs.Count(z => z.Name.EndsWith('d'))))
                                    .ToList()
                                    .FirstOrDefault();

            Console.WriteLine($"The name of the artist that has most songs which end on the letter 'd' is {artistsWithMostDs.FullName}.");



            //var albumsWithMostDs = Albums.OrderByDescending(x => x.Songs.Where(y => y.Name.EndsWith("d")).Count()).ToList().FirstOrDefault();
            //Console.WriteLine(albumsWithMostDs.Name);

            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)



            Console.ReadLine();
        }
Exemple #8
0
        static void Main(string[] args)
        {
            Init();// this method fills the arrays above with data

            // - print the mass of the earth on July 1895 XD

            /*
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░
             *  ░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███░░░░░░
             *  ░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒███░░░░
             *  ░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░
             *  ░░░░█▒▒▒▒▒█░░░██▒▒▒▒▄██▄▒▒▒▒▄██▄▒▒▒███░
             *  ░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒██
             *  ░░░█████████████▒▒▒▒▀██▀▒▒▒▒▀██▀▒▒▒▒▒██
             *  ░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒██
             *  ░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒██▒▒▒▒██
             *  ██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒██▒▒▒▒▒██
             *  █▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒███████▒▒▒▒▒▒▒██
             *  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░
             *  ░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██░░░
             *  ░██▒▒▒▒▒▒▒▒▒▒▒███▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░░
             *  ░░████████████░░░████████████████░░░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░▄█████▄░▄███████▄░▄███████▄░██████▄░░
             *  ░░██▒▒▒▒█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░██▒▒▒▒▒░██▒▒▒▒▒██░██▒▒▒▒▒██░██▒▒▒██░░
             *  ░░██▒▒▒▀█░███▒▒▒███░███▒▒▒███░██▒▒▒██░░
             *  ░░▀█████▀░▀███████▀░▀███████▀░██████▀░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░▄█████░██▒▒▒▒██▀░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▀▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░██▒▒▒▒░██▒▒▒██░██▒▒▒▒░█████▀░░░░░░░
             *  ░░░░██▒▒▒▒░██▄▒▄██░██▄▒▒▒░██▒▒▒██░░░░░░
             *  ░░░░▀█████░▀█████▀░▀█████░██▒▒▒▒██▄░░░░
             *  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
             */

            // QUERIES!

            // - how many Songs start with the letter 'a' (case insensitive)
            // - how many artists end with letter 'a' (case insensitive)
            // - whats the name of the song with longest duration
            // - whats the total Duration of all Songs
            // - how many albums have Songs longer than 300 seconds
            // - print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            // - print the name of the album that has highest Average duration of a song
            // - how many characters has the song that has the shortest Duration
            // - print the name and the genre of the album that has most songs
            // - print the name of the artist that has most songs
            // - print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            // - print the average song duration, of the album that has most songs

            // Bonus:
            // - print the longest song duration of the album that has least songs
            // - print the name of the album that has most songs that contain letter 'a' in the name
            // - print the name of the artist that has most songs that end with letter 'd'



            // ************ Don't mind the structure, focus on the lists declared on the beginning of Program.cs ****************

            // 3, 2, 1.... GO! :)



            Console.ForegroundColor = ConsoleColor.Green;


            // 1. How many Songs start with the letter 'a' (case insensitive)

            int songsWithA = Songs.Where(song => song.Name.ToLower().StartsWith('a')).Count();

            Console.WriteLine($"{songsWithA} Songs start with the letter 'a'");



            Console.WriteLine(new string('-', 60));



            // 2. How many artists end with letter 'a'(case insensitive)
            List <Artist> artistsEndWithA = Artists.Where(artist => artist.FullName.EndsWith('a')).ToList();

            artistsEndWithA.ForEach(artist => Console.WriteLine($"{artist.FullName.Length} artists end with letter 'a'. "));



            Console.WriteLine(new string('-', 60));



            // 3. Whats the name of the song with longest duration
            double longestDurationOf = Songs.Max(x => x.Duration);

            var longestDurationSong = Songs
                                      .Where(song => song.Duration == longestDurationOf)
                                      .Select(x => new { x.Name, x.Duration })
                                      .FirstOrDefault();

            Console.WriteLine($"The name of song with longest duration is: {longestDurationSong.Name} - {longestDurationSong.Duration} duration");



            Console.WriteLine(new string('-', 60));



            // 4. Whats the total Duration of all Songs
            double totalDurationOf = Songs.Sum(x => x.Duration);

            Console.WriteLine($"Total duration of All songs is - {totalDurationOf}");



            Console.WriteLine(new string('-', 60));



            // 5. How many albums have Songs longer than 300 seconds
            var songsLongerThan = Albums.Where(x => x.Songs.Max(x => x.Duration > 300)).Select(x => x.Name).Count();

            Console.WriteLine($"{songsLongerThan} albums have Songs longer than 300 seconds.");



            Console.WriteLine(new string('-', 60));



            // 6. Print the names of the artists(separated with "--"), that have more than one album of PopRock genre
            List <Artist> popRockArtists = Artists.Where(x => x.Albums.Max(x => x.Genre.Equals(Genre.PopRock))).ToList();

            Console.WriteLine("Pop Rock Artists Name: \n");
            popRockArtists.ForEach(x => Console.Write($"-- {x.FullName} \n"));



            Console.WriteLine(new string('-', 60));



            //7. Print the name of the album that has highest Average duration of a song
            var printAlbum = Albums.OrderByDescending(x => x.Songs.Average(x => x.Duration)).First();

            Console.WriteLine($"The name of the album that has highest Average duration of a song is {printAlbum.Name}.");



            Console.WriteLine(new string('-', 60));



            // 8. How many characters has the song that has the shortest Duration
            double shortSong = Songs.Min(x => x.Duration);

            var shortestDuration = Songs
                                   .Where(song => song.Duration == shortSong)
                                   .Select(x => x.Name)
                                   .SingleOrDefault();

            Console.WriteLine($"The Song with shortest duration have {shortestDuration.Length} characters");



            Console.WriteLine(new string('-', 60));



            // 9. Print the name and the genre of the album that has most songs
            double mostSongs = Albums.Max(x => x.Songs.Count);

            var mostSongsAlbum = Albums.Where(album => album.Songs.Count == mostSongs)
                                 .Select(x => new { x.Name, x.Genre })
                                 .SingleOrDefault();

            Console.WriteLine($"Name and the genre of the album that has most songs is {mostSongsAlbum.Name} - {mostSongsAlbum.Genre} Genre");



            Console.WriteLine(new string('-', 60));



            //10. Print the name of the artist that has most songs
            var songs = Albums.Max(x => x.Songs.Count);

            var mostSongsArtist = Artists.Where(x => x.Albums.Max(x => x.Songs.Count == songs))
                                  .Select(x => x.FullName)
                                  .SingleOrDefault();


            Console.WriteLine($"The name of the artist that has most songs is {mostSongsArtist}");



            Console.WriteLine(new string('-', 60));



            // 11. Print the type of the artist(SoloArtist/Band) that has most albums published before year 2000
            var albumYear = Albums.Where(x => x.Year < 2000)
                            .Select(x => x.Year)
                            .ToList();

            var printArtist = Artists.Where(x => x.Albums.Max(x => x.Name)
                                            .Equals(albumYear))
                              .Select(x => x.ArtistType)
                              .SingleOrDefault();


            Console.WriteLine($"Type of the artist that has most albums published before year 2000 is ({printArtist})");



            Console.WriteLine(new string('-', 60));



            // 12. Print the average song duration, of the album that has most songs
            double averageSongDuration = Albums.Max(x => x.Songs.Average(x => x.Duration));

            Console.WriteLine($"Average song duration of the album that has most songs is - {averageSongDuration}");


            //var averageSongDuration = Albums.OrderByDescending(a => a.Songs.Count)
            //                          .Select(a => a.Songs.Average(s => s.Duration))
            //                          .FirstOrDefault();
            //Console.WriteLine(averageSongDuration);



            Console.WriteLine(new string('-', 60));



            // Bonus:

            //1. Print the longest song duration of the album that has least songs
            double leastSongsAlbum = Albums.Min(x => x.Songs.Count());


            var longestSongDuration = Albums.Where(x => x.Songs.Count == leastSongsAlbum).Select(x => x.Songs).Take(1).ToList();

            longestSongDuration.ForEach(x => Console.WriteLine($"Longest song duration of two albums with the {x.Count} songs that has least song is - {x.Max(x => x.Duration)} duration, but I taked the first album."));



            Console.WriteLine(new string('-', 60));



            //2. Print the name of the album that has most songs that contain letter 'a' in the name
            var mostSongsWithA = Albums.OrderByDescending(x => x.Songs.Sum(x => x.Name.Take('a').Count()))
                                 .Select(x => x.Name)
                                 .FirstOrDefault();

            Console.WriteLine($"The name of the album that has most songs that contain letter 'a' in the name is {mostSongsWithA}");



            Console.WriteLine(new string('-', 60));



            //3. - Print the name of the artist that has most songs that end with letter 'd'
            var mostSongsWithD = Artists.OrderByDescending(x => x.Albums.Count(x => x.Songs.Max(x => x.Name.EndsWith('d'))))
                                 .Select(x => x.FullName)
                                 .FirstOrDefault();

            Console.WriteLine($"The name of the artist that has most songs that end with letter 'd' is {mostSongsWithD}");



            Console.ReadLine();
        }