static void Main(string[] args)
        {
            var Rock            = new Genre("Rock");
            var AltRock         = new SubGenre("Alt Rock", Rock);
            var FallOutBoy      = new Artist("Fall Out Boy", AltRock);
            var SaveRockAndRoll = new Album("Save Rock and Roll", 2013, FallOutBoy);

            SaveRockAndRoll.AddTrack(new Track(FallOutBoy, SaveRockAndRoll, "The Phoenix"));
            SaveRockAndRoll.AddTrack(new Track(FallOutBoy, SaveRockAndRoll, "Alone Together"));
            SaveRockAndRoll.AddTrack(new Track(FallOutBoy, SaveRockAndRoll, "The Mighty Fall"));
            SaveRockAndRoll.AddTrack(new Track(FallOutBoy, SaveRockAndRoll, "Death Valley"));
            SaveRockAndRoll.AddTrack(new Track(FallOutBoy, SaveRockAndRoll, "Just One Yesterday"));

            var AmBeautyAmPsycho = new Album("American Beauty / American Psycho", 2014, FallOutBoy);

            AmBeautyAmPsycho.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Irresistible"));
            AmBeautyAmPsycho.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Centuries"));
            AmBeautyAmPsycho.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Uma Thurman"));
            AmBeautyAmPsycho.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Novocaine"));
            AmBeautyAmPsycho.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Immortals"));

            FallOutBoy.AddAlbum(SaveRockAndRoll);
            FallOutBoy.AddAlbum(AmBeautyAmPsycho);

            //Console.WriteLine(AmBeautyAmPsycho.Artist.Albums[0].Name);

            var Catalog = new Catalog("First Catalog");

            Catalog.AddAlbum(SaveRockAndRoll);
            Catalog.AddAlbum(AmBeautyAmPsycho);

            var Pop        = new Genre("Pop");
            var DemiLovato = new Artist("Demi Lovato", Pop);
            var Confident  = new Album("Confident", 2015, DemiLovato);

            Confident.AddTrack(new Track(DemiLovato, Confident, "Confident"));
            Confident.AddTrack(new Track(DemiLovato, Confident, "Kingdom Come"));
            Confident.AddTrack(new Track(DemiLovato, Confident, "Old Ways"));

            DemiLovato.AddAlbum(Confident);
            Catalog.AddAlbum(Confident);

            var TheBestOfAll = new TrackCollection("The Best Of All");

            TheBestOfAll.AddTrack(new Track(DemiLovato, Confident, "Confident"));
            TheBestOfAll.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Immortals"));
            TheBestOfAll.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Irresistible"));
            TheBestOfAll.AddTrack(new Track(FallOutBoy, AmBeautyAmPsycho, "Centuries"));

            Catalog.AddTrackCollection(TheBestOfAll);

            Search search = new Search(Catalog);

            search.SearchArtists();
            search.SearchAlbums();
            search.SearchArtistsWithGenre(AltRock);

            search.MultiPurposeTrackSearch();
        }
示例#2
0
        public void ReadFromFile(String path)
        {
            using (StreamReader reader = new StreamReader(path))
            {
                String line;
                while ((line = reader.ReadLine()) != null)
                {
                    String[] lines = line.Split(" - ");

                    Artist     a  = new Artist(lines[0]);
                    Genre      g  = new Genre(lines[3]);
                    Collection c  = new Collection(lines[4]);
                    int        d  = Convert.ToInt32(lines[5]);
                    Album      al = new Album(lines[1], d, g);
                    Track      t  = new Track(lines[2], a, g, al, c, d);
                    if (!_albums.Contains(al))
                    {
                        al.AddTrack(t);
                        _albums.Add(al);
                    }
                    else
                    {
                        FindAlbum(al).AddTrack(t);
                    }

                    if (!_artists.Contains(a))
                    {
                        a.AddTrack(t);
                        _artists.Add(a);
                    }
                    else
                    {
                        FindArtist(a).AddTrack(t);
                    }

                    if (!_collections.Contains(c))
                    {
                        c.AddTrack(t);
                        _collections.Add(c);
                    }
                    else
                    {
                        FindCollection(c).AddTrack(t);
                    }

                    if (!_genres.Contains(g))
                    {
                        g.AddTrack(t);
                        _genres.Add(g);
                    }
                    else
                    {
                        FindGenre(g).AddTrack(t);
                    }

                    _tracks.Add(t);
                }
            }

            _collections.Sort();
            _genres.Sort();
            _albums.Sort();
            _tracks.Sort();
            _artists.Sort();
        }