//Return the Album Count of the Artist inputted static int AlbumCount(Artist art) { //Return amount of albums Artist has made return(art.ReturnAlbums().Count()); }
//Adds album to the artistList static void AddAlbum() { //Clears console and creates temporary variables Console.Clear(); Artist artistStore = null; //Album albumType; bool inList = false; bool reduntantEntry = false; //Prompt user for input of an artist name and album name string ArtistName = InputArtist(); string AlbumName = InputAlbum(); string AlbumType = InputType(); //If there is an artist already with the same name in the list foreach (Artist art in artistList) { if (art.ArtistName == ArtistName) { //For each album by an artist foreach (Album alb in art.ReturnAlbums()) { //If there is already an album with the same name set as a redundant entry if (alb.AlbumName == AlbumName) { reduntantEntry = true; } } if (!reduntantEntry) { //Set artist to temporary variable and escape loop artistStore = art; inList = true; break; } else { Console.WriteLine(ArtistName + " - " + AlbumName + " is already present in list\n"); MenuPrompt(); } } } //If already in the list if (inList) { switch (AlbumType) { case "Cd": case "Full Length": case "Full-Length": artistStore.AddAlbum(new CD(AlbumName)); break; case "Ep": artistStore.AddAlbum(new EP(AlbumName)); break; case "Vinyl": artistStore.AddAlbum(new Vinyl(AlbumName)); break; case "Digital": artistStore.AddAlbum(new Digital(AlbumName)); break; case "Cassette": artistStore.AddAlbum(new Cassette(AlbumName)); break; } } else { switch (AlbumType) { case "Cd": case "Full Length": case "Full-Length": artistList.Add(new Artist(ArtistName, new List <Album> { new CD(AlbumName) })); break; case "Ep": artistList.Add(new Artist(ArtistName, new List <Album> { new EP(AlbumName) })); break; case "Vinyl": artistList.Add(new Artist(ArtistName, new List <Album> { new Vinyl(AlbumName) })); break; case "Digital": artistList.Add(new Artist(ArtistName, new List <Album> { new Digital(AlbumName) })); break; case "Cassette": artistList.Add(new Artist(ArtistName, new List <Album> { new Cassette(AlbumName) })); break; } } //Sorts artist list where needed and saves information to JSON, taking user to menu again SortArtists(); SaveJSON(); Initialise(); }